diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-03-09 22:20:20 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-03-09 22:20:20 +0000 |
commit | d81cb40c880dfaeb203eeba6c21189c9e2995c49 (patch) | |
tree | 21170e5105722a7adcb649f375dd8253fd74ff31 /libvo | |
parent | 0b48e1514030803d34ac0de872a81cd7b2d1e25f (diff) | |
download | mpv-d81cb40c880dfaeb203eeba6c21189c9e2995c49.tar.bz2 mpv-d81cb40c880dfaeb203eeba6c21189c9e2995c49.tar.xz |
free resources when load_raw fails
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17792 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/font_load.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libvo/font_load.c b/libvo/font_load.c index e7473f1250..be445de86a 100644 --- a/libvo/font_load.c +++ b/libvo/font_load.c @@ -17,15 +17,15 @@ raw_file* load_raw(char *name,int verbose){ raw_file* raw=malloc(sizeof(raw_file)); unsigned char head[32]; FILE *f=fopen(name,"rb"); - if(!f) return NULL; // can't open - if(fread(head,32,1,f)<1) return NULL; // too small - if(memcmp(head,"mhwanh",6)) return NULL; // not raw file + if(!f) goto err_out; // can't open + if(fread(head,32,1,f)<1) goto err_out; // too small + if(memcmp(head,"mhwanh",6)) goto err_out; // not raw file raw->w=head[8]*256+head[9]; raw->h=head[10]*256+head[11]; raw->c=head[12]*256+head[13]; if(raw->w == 0) // 2 bytes were not enough for the width... read 4 bytes from the end of the header raw->w = ((head[28]*0x100 + head[29])*0x100 + head[30])*0x100 + head[31]; - if(raw->c>256) return NULL; // too many colors!? + if(raw->c>256) goto err_out; // too many colors!? mp_msg(MSGT_OSD, MSGL_DBG2, "RAW: %s %d x %d, %d colors\n",name,raw->w,raw->h,raw->c); if(raw->c){ raw->pal=malloc(raw->c*3); @@ -39,6 +39,12 @@ raw_file* load_raw(char *name,int verbose){ fread(raw->bmp,raw->h*raw->w*bpp,1,f); fclose(f); return raw; + +err_out: + if (f) + fclose(f); + free(raw); + return NULL; } extern int sub_unicode; |