some memory leaks fixed

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13642 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2004-10-14 15:09:35 +00:00
parent e652c2fe8a
commit 82f168a4f6
4 changed files with 36 additions and 19 deletions

View File

@ -164,6 +164,7 @@ static int init(sh_audio_t *sh)
static void uninit(sh_audio_t *sh)
{
struct ov_struct_st *ov = sh->context;
vorbis_dsp_clear(&ov->vd);
vorbis_block_clear(&ov->vb);
vorbis_info_clear(&ov->vi);
free(ov);

View File

@ -163,9 +163,14 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
return vf->next->query_format(vf->next,best);
}
static void uninit(vf_instance_t *vf) {
free(vf->priv);
}
static int open(vf_instance_t *vf, char* args){
unsigned int i;
vf->config=config;
vf->uninit=uninit;
vf->put_image=put_image;
vf->query_format=query_format;
vf->priv=malloc(sizeof(struct vf_priv_s));

View File

@ -1424,8 +1424,13 @@ void demux_close_ogg(demuxer_t* demuxer) {
subcp_close();
#endif
ogg_sync_clear(&ogg_d->sync);
if(ogg_d->subs)
{
for (i = 0; i < ogg_d->num_sub; i++)
ogg_stream_clear(&ogg_d->subs[i].stream);
free(ogg_d->subs);
}
if(ogg_d->syncpoints)
free(ogg_d->syncpoints);
if (ogg_d->text_ids)

View File

@ -56,10 +56,10 @@ int fontdb=-1;
int version=0;
int first=1;
desc=malloc(sizeof(font_desc_t));if(!desc) return NULL;
desc=malloc(sizeof(font_desc_t));if(!desc) goto fail_out;
memset(desc,0,sizeof(font_desc_t));
f=fopen(fname,"rt");if(!f){ printf("font: can't open file: %s\n",fname); return NULL;}
f=fopen(fname,"rt");if(!f){ printf("font: can't open file: %s\n",fname); goto fail_out;}
i = strlen (fname) - 9;
if ((dn = malloc(i+1))){
@ -98,10 +98,7 @@ while(fgets(sor,1020,f)){
if (first) {
if (!sor[0] || sor[1] == 1 || (sor[0] == 'M' && sor[1] == 'Z') || (sor[0] == 0x1f && sor[1] == 0x8b) || (sor[0] == 1 && sor[1] == 0x66)) {
printf("%s doesn't look like a font description, ignoring\n", fname);
fclose(f);
free(desc);
free(dn);
return NULL;
goto fail_out;
}
first = 0;
}
@ -141,7 +138,7 @@ while(fgets(sor,1020,f)){
if(verbose) printf("font: Reading section: %s\n",section);
if(strcmp(section,"[files]")==0){
++fontdb;
if(fontdb>=16){ printf("font: Too many bitmaps defined!\n");return NULL;}
if(fontdb>=16){ printf("font: Too many bitmaps defined!\n");goto fail_out;}
}
continue;
}
@ -160,20 +157,20 @@ while(fgets(sor,1020,f)){
char *default_dir=MPLAYER_DATADIR "/font";
if(pdb==2 && strcmp(p[0],"alpha")==0){
char *cp;
if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) return NULL;
if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) goto fail_out;
snprintf(cp,strlen(desc->fpath)+strlen(p[1])+2,"%s/%s",
desc->fpath,p[1]);
if(!((desc->pic_a[fontdb]=load_raw(cp,verbose)))){
free(cp);
if (!(cp=malloc(strlen(default_dir)+strlen(p[1])+2)))
return NULL;
goto fail_out;
snprintf(cp,strlen(default_dir)+strlen(p[1])+2,"%s/%s",
default_dir,p[1]);
if (!((desc->pic_a[fontdb]=load_raw(cp,verbose)))){
printf("Can't load font bitmap: %s\n",p[1]);
free(cp);
return NULL;
goto fail_out;
}
}
free(cp);
@ -181,20 +178,20 @@ while(fgets(sor,1020,f)){
}
if(pdb==2 && strcmp(p[0],"bitmap")==0){
char *cp;
if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) return NULL;
if (!(cp=malloc(strlen(desc->fpath)+strlen(p[1])+2))) goto fail_out;
snprintf(cp,strlen(desc->fpath)+strlen(p[1])+2,"%s/%s",
desc->fpath,p[1]);
if(!((desc->pic_b[fontdb]=load_raw(cp,verbose)))){
free(cp);
if (!(cp=malloc(strlen(default_dir)+strlen(p[1])+2)))
return NULL;
goto fail_out;
snprintf(cp,strlen(default_dir)+strlen(p[1])+2,"%s/%s",
default_dir,p[1]);
if (!((desc->pic_b[fontdb]=load_raw(cp,verbose)))){
printf("Can't load font bitmap: %s\n",p[1]);
free(cp);
return NULL;
goto fail_out;
}
}
free(cp);
@ -245,17 +242,15 @@ while(fgets(sor,1020,f)){
}
}
printf("Syntax error in font desc: %s\n",sor);
free(desc);
fclose(f);
return NULL;
goto fail_out;
}
fclose(f);
f = NULL;
if (first == 1) {
printf("%s is empty or a directory, ignoring\n", fname);
free(desc);
return NULL;
goto fail_out;
}
//printf("font: pos of U = %d\n",desc->start[218]);
@ -263,7 +258,7 @@ fclose(f);
for(i=0;i<=fontdb;i++){
if(!desc->pic_a[i] || !desc->pic_b[i]){
printf("font: Missing bitmap(s) for sub-font #%d\n",i);
return NULL;
goto fail_out;
}
//if(factor!=1.0f)
{
@ -316,6 +311,17 @@ desc->width[' ']=desc->spacewidth;
printf("Font %s loaded successfully! (%d chars)\n",fname,chardb);
return desc;
fail_out:
if (f)
fclose(f);
if (desc->fpath)
free(desc->fpath);
if (desc->name)
free(desc->name);
if (desc)
free(desc);
return NULL;
}
#if 0