[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[44] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2009-12-16 17:30:28
|
Revision: 44 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=44&view=rev Author: nickols_k Date: 2009-12-16 17:30:20 +0000 (Wed, 16 Dec 2009) Log Message: ----------- cppcheck: fixed some out-of-bounds and memory,resources leak Modified Paths: -------------- mplayerxp/libmpdemux/cookies.c mplayerxp/libmpdemux/demux_audio.c mplayerxp/libmpdemux/demux_film.c mplayerxp/libmpdemux/demux_fli.c mplayerxp/libmpdemux/http.c mplayerxp/libmpdemux/mux_lavf.c mplayerxp/libmpdemux/sub_ty.c mplayerxp/libvo/font_load.c mplayerxp/libvo/gl_common.c mplayerxp/libvo/vo_vdpau.c mplayerxp/m_option.c mplayerxp/playtree.c mplayerxp/postproc/af.c mplayerxp/subreader.c mplayerxp/vobsub.c Modified: mplayerxp/libmpdemux/cookies.c =================================================================== --- mplayerxp/libmpdemux/cookies.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libmpdemux/cookies.c 2009-12-16 17:30:20 UTC (rev 44) @@ -109,11 +109,13 @@ if (*length < 0) { MSG_V("Could not find EOF"); + close(fd); return NULL; } if (*length > SIZE_MAX - 1) { MSG_V("File too big, could not malloc."); + close(fd); return NULL; } @@ -121,11 +123,14 @@ if (!(buffer = malloc(*length + 1))) { MSG_V("Could not malloc."); + close(fd); return NULL; } if (read(fd, buffer, *length) != *length) { + free(buffer); MSG_V("Read is behaving funny."); + close(fd); return NULL; } close(fd); Modified: mplayerxp/libmpdemux/demux_audio.c =================================================================== --- mplayerxp/libmpdemux/demux_audio.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libmpdemux/demux_audio.c 2009-12-16 17:30:20 UTC (rev 44) @@ -958,7 +958,7 @@ else { int fmt; - char b[12]; + char b[21]; MSG_DBG2("initial mp3_header: 0x%08X at %lu\n",*(uint32_t *)hdr,st_pos); if((n = mp_decode_mp3_header(hdr,&fmt,&mp3_brate,&mp3_samplerate,&mp3_channels)) > 0) { Modified: mplayerxp/libmpdemux/demux_film.c =================================================================== --- mplayerxp/libmpdemux/demux_film.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libmpdemux/demux_film.c 2009-12-16 17:30:20 UTC (rev 44) @@ -225,6 +225,7 @@ if (chunk_type != CHUNK_FILM) { MSG_ERR( "Not a FILM file\n"); + free(film_data); return NULL; } Modified: mplayerxp/libmpdemux/demux_fli.c =================================================================== --- mplayerxp/libmpdemux/demux_fli.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libmpdemux/demux_fli.c 2009-12-16 17:30:20 UTC (rev 44) @@ -94,12 +94,14 @@ demuxer->movi_end = stream_read_dword_le(demuxer->stream); magic_number = stream_read_word_le(demuxer->stream); - + if ((magic_number != 0xAF11) && (magic_number != 0xAF12)) { MSG_ERR("Bad/unknown magic number (%04x)\n", magic_number); - return(NULL); + free(header); + free(frames); + return(NULL); } // fetch the number of frames Modified: mplayerxp/libmpdemux/http.c =================================================================== --- mplayerxp/libmpdemux/http.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libmpdemux/http.c 2009-12-16 17:30:20 UTC (rev 44) @@ -288,6 +288,7 @@ new_field->field_name = (char*)malloc(strlen(field_name)+1); if( new_field->field_name==NULL ) { MSG_FATAL("Memory allocation failed\n"); + free(new_field); return; } strcpy( new_field->field_name, field_name ); Modified: mplayerxp/libmpdemux/mux_lavf.c =================================================================== --- mplayerxp/libmpdemux/mux_lavf.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libmpdemux/mux_lavf.c 2009-12-16 17:30:20 UTC (rev 44) @@ -429,6 +429,7 @@ if(!load_dll(codec_name("libavformat"SLIBSUFFIX))) /* try local copy first */ { MSG_ERR("Detected error during loading libavformat.so! Try to upgrade this library\n"); + free(priv); return 0; } av_register_all(); Modified: mplayerxp/libmpdemux/sub_ty.c =================================================================== --- mplayerxp/libmpdemux/sub_ty.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libmpdemux/sub_ty.c 2009-12-16 17:30:20 UTC (rev 44) @@ -590,7 +590,7 @@ { char line[ 80 ]; - if ( b1 < 0x0F ) + if ( b1 < 0x0F ) { // start packet TY_XDS_length = 0; TY_XDS_mode = b1 >> 1; // every other mode is a resume @@ -600,7 +600,7 @@ } TY_XDS_checksum += b1 + b2; - + // eof (next byte is checksum) if ( b1 == 0x0F ) { @@ -609,10 +609,10 @@ { if ( TY_OSD_debug > 3 && !TY_XDS_length ) { - MSG_DBG3( + MSG_DBG3( "%% TY_XDS CHECKSUM ERROR (ignoring)\n" ); - } - else + } + else { TY_XDS_mode = 0; TY_XDS_type = 0; @@ -655,14 +655,14 @@ case 0x0301: // future { char *mon[] = - { + { "0", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "13", "14", "15" }; ty_AddXDSToDisplay( "AIR DATE: %s %2d %d:%02d:00", mon[ TY_XDS_ptr[ 3 ] & 0x0f ], TY_XDS_ptr[ 2 ] & 0x1f, - TY_XDS_ptr[ 1 ] & 0x1f, + TY_XDS_ptr[ 1 ] & 0x1f, TY_XDS_ptr[ 0 ] & 0x3f ); @@ -713,19 +713,19 @@ sprintf( line, "%sRATING: %s", line, TY_XDS_CHIP[ ( TY_XDS_ptr[ 0 ] & 0x08 ) >> 3 ] [ TY_XDS_ptr[ 1 ] & 0x07 ] ); - if ( TY_XDS_ptr[ 0 ] & 0x20 ) + if ( TY_XDS_ptr[ 0 ] & 0x20 ) sprintf( line, "%s DIALOGUE", line ); - if ( TY_XDS_ptr[ 1 ] & 0x08 ) + if ( TY_XDS_ptr[ 1 ] & 0x08 ) sprintf( line, "%s LANGUAGE", line ); - if ( TY_XDS_ptr[ 1 ] & 0x10 ) + if ( TY_XDS_ptr[ 1 ] & 0x10 ) sprintf( line, "%s SEXUAL", line ); - if ( TY_XDS_ptr[ 1 ] & 0x20 ) + if ( TY_XDS_ptr[ 1 ] & 0x20 ) sprintf( line, "%s VIOLENCE", line ); ty_AddXDSToDisplay( line ); // raw output for verification. if ( TY_OSD_debug > 1 ) - MSG_DBG3( " (%02x %02x)", + MSG_DBG3( " (%02x %02x)", TY_XDS_ptr[ 0 ], TY_XDS_ptr[ 1 ] ); break; } @@ -734,7 +734,7 @@ case 0x0306: // future { // requires table, never actually seen it used either - ty_AddXDSToDisplay( "AUDIO: %02x %02x", TY_XDS_ptr[ 0 ], + ty_AddXDSToDisplay( "AUDIO: %02x %02x", TY_XDS_ptr[ 0 ], TY_XDS_ptr[ 1 ] ); break; } @@ -743,7 +743,7 @@ case 0x0309: // future { // requires table, rare - ty_AddXDSToDisplay( "ASPECT: %02x %02x", + ty_AddXDSToDisplay( "ASPECT: %02x %02x", TY_XDS_ptr[ 0 ], TY_XDS_ptr[ 1 ] ); break; } @@ -763,13 +763,13 @@ case 0x0501: // channel network name { - ty_AddXDSToDisplay( "NETWORK: %s", TY_XDS_ptr ); + ty_AddXDSToDisplay( "NETWORK: %s", TY_XDS_ptr ); break; } case 0x0502: // channel network call letters { - ty_AddXDSToDisplay( "CALLSIGN: %s", TY_XDS_ptr ); + ty_AddXDSToDisplay( "CALLSIGN: %s", TY_XDS_ptr ); break; } @@ -792,11 +792,11 @@ time_t time_t = mktime( &tm ); char *timestr; - + time_t -= ( ( TIMEZONE - DST ) * 60 * 60 ); timestr = ctime( &time_t ); timestr[ strlen( timestr ) - 1 ] = 0; - + sprintf( line, "%sCUR.TIME: %s ", line, timestr ); if ( TY_XDS[ 3 ][ 4 ][ 0 ] ) { @@ -813,7 +813,7 @@ case 0x0704: //misc. local time zone { - sprintf( line, "%sTIMEZONE: UTC-%d", + sprintf( line, "%sTIMEZONE: UTC-%d", line, TY_XDS_ptr[ 0 ] & 0x1f ); if ( TY_XDS_ptr[ 0 ] & 0x20 ) sprintf( line, "%s DST", line ); ty_AddXDSToDisplay( line ); @@ -822,26 +822,26 @@ default: { - MSG_DBG3( "UNKNOWN CLASS %d TYPE %d", + MSG_DBG3( "UNKNOWN CLASS %d TYPE %d", ( TY_XDS_mode << 1 ) + 1, TY_XDS_type ); - if ( TY_OSD_debug > 1 ) + if ( TY_OSD_debug > 1 ) { int x; MSG_DBG3( "\nDUMP:\n" ); for ( x = 0 ; x < TY_XDS_length ; x++ ) - MSG_DBG3( " %02x %c", + MSG_DBG3( " %02x %c", TY_XDS_ptr[ x ], TY_XDS_ptr[ x ] ); MSG_DBG3( "\n" ); - } + } } } - if ( TY_OSD_debug > 1 ) + if ( TY_OSD_debug > 1 ) MSG_DBG3( " (%d)", TY_XDS_length ); } TY_XDS_mode = 0; TY_XDS_type = 0; } - else if ( TY_XDS_length < 34 ) + else if ( TY_XDS_length < 34 ) { TY_XDS_new[ TY_XDS_mode ][ TY_XDS_type ][ TY_XDS_length++ ] = b1; TY_XDS_new[ TY_XDS_mode ][ TY_XDS_type ][ TY_XDS_length++ ] = b2; @@ -895,7 +895,7 @@ // printf( "OSD:%d:%s\n", index, ty_OSD1.text[ index ] ); // } vo_sub = &ty_OSD1; - vo_osd_changed( OSDTYPE_SUBTITLE ); + vo_osd_changed( OSDTYPE_SUBTITLE ); tyOSDUpdate = 0; } } Modified: mplayerxp/libvo/font_load.c =================================================================== --- mplayerxp/libvo/font_load.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libvo/font_load.c 2009-12-16 17:30:20 UTC (rev 44) @@ -16,15 +16,15 @@ 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) { free(raw); return NULL; } // can't open + if(fread(head,32,1,f)<1) { free(raw); fclose(f); return NULL; } // too small + if(memcmp(head,"mhwanh",6)) { free(raw); fclose(f); return NULL; } // 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) { free(raw); fclose(f); return NULL; } // too many colors!? MSG_V("RAW: %s %d x %d, %d colors\n",name,raw->w,raw->h,raw->c); if(raw->c){ raw->pal=malloc(raw->c*3); @@ -55,7 +55,7 @@ desc=malloc(sizeof(font_desc_t));if(!desc) return NULL; memset(desc,0,sizeof(font_desc_t)); -f=fopen(fname,"rt");if(!f){ MSG_ERR("font: can't open file: %s\n",fname); return NULL;} +f=fopen(fname,"rt");if(!f){ MSG_ERR("font: can't open file: %s\n",fname); free(desc); return NULL;} i = strlen (fname) - 9; if ((dn = malloc(i+1))){ Modified: mplayerxp/libvo/gl_common.c =================================================================== --- mplayerxp/libvo/gl_common.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libvo/gl_common.c 2009-12-16 17:30:20 UTC (rev 44) @@ -452,8 +452,10 @@ return 0; bpp = (m > 255) ? 6 : 3; data = malloc(w * h * bpp); - if (fread(data, w * bpp, h, f) != h) + if (fread(data, w * bpp, h, f) != h) { + free(data); return 0; + } if (!fmt) { fmt = (m > 255) ? hqtexfmt : 3; if (fmt == GL_FLOAT_RGB32_NV && target != GL_TEXTURE_RECTANGLE) Modified: mplayerxp/libvo/vo_vdpau.c =================================================================== --- mplayerxp/libvo/vo_vdpau.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/libvo/vo_vdpau.c 2009-12-16 17:30:20 UTC (rev 44) @@ -146,7 +146,7 @@ #define osd_surface output_surfaces[NUM_OUTPUT_SURFACES] static VdpOutputSurface output_surfaces[NUM_OUTPUT_SURFACES + 1]; static VdpVideoSurface deint_surfaces[3]; -static mp_image_t *deint_mpi[2]; +static mp_image_t *deint_mpi[3]; static uint32_t output_surface_width, output_surface_height; static VdpVideoMixer video_mixer; Modified: mplayerxp/m_option.c =================================================================== --- mplayerxp/m_option.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/m_option.c 2009-12-16 17:30:20 UTC (rev 44) @@ -1470,11 +1470,12 @@ m_obj_params_t* p = opt->priv; const m_struct_t* desc; char* cpy = strdup(param); - + // We need the object desc - if(!p) + if(!p) { + free(cpy); return M_OPT_INVALID; - + } desc = p->desc; r = get_obj_params(name,desc->name,cpy,desc,p->separator,dst ? &opts : NULL); free(cpy); Modified: mplayerxp/playtree.c =================================================================== --- mplayerxp/playtree.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/playtree.c 2009-12-16 17:30:20 UTC (rev 44) @@ -816,6 +816,7 @@ strncpy(s,entry,val-e); s[val-e] = '\0'; } + free(val); return playtree_ret_filename; } else { if(iter->config) Modified: mplayerxp/postproc/af.c =================================================================== --- mplayerxp/postproc/af.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/postproc/af.c 2009-12-16 17:30:20 UTC (rev 44) @@ -117,16 +117,17 @@ if(!_new){ MSG_ERR(MSGTR_OutOfMemory); return NULL; - } + } memset(_new,0,sizeof(af_instance_t)); _new->parent=s; // Check for commandline parameters strsep(&cmdline, "="); // Find filter from name - if(NULL == (_new->info=af_find(name))) + if(NULL == (_new->info=af_find(name))) { + free(_new); return NULL; - + } /* Make sure that the filter is not already in the list if it is non-reentrant */ if(_new->info->flags & AF_FLAGS_NOT_REENTRANT){ @@ -137,9 +138,9 @@ return NULL; } } - + MSG_V("[libaf] Adding filter %s \n",name); - + // Initialize the new filter if(AF_OK == _new->info->open(_new) && AF_ERROR < _new->control(_new,AF_CONTROL_POST_CREATE,&s->cfg)){ @@ -148,12 +149,11 @@ return _new; } else - return _new; + return _new; } - + free(_new); - MSG_ERR("[libaf] Couldn't create or open audio filter '%s'\n", - name); + MSG_ERR("[libaf] Couldn't create or open audio filter '%s'\n", name); return NULL; } Modified: mplayerxp/subreader.c =================================================================== --- mplayerxp/subreader.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/subreader.c 2009-12-16 17:30:20 UTC (rev 44) @@ -659,9 +659,9 @@ fd=fopen (filename, "r"); if (!fd) return NULL; sub_format=sub_autodetect (fd); - if (sub_format==SUB_INVALID) { MSG_ERR ("SUB: Could not determine file format\n");return NULL;} + if (sub_format==SUB_INVALID) { MSG_ERR ("SUB: Could not determine file format\n"); fclose(fd); return NULL;} MSG_INFO ("SUB: Detected subtitle file format: %s\n", fmtname[sub_format]); - + rewind (fd); #ifdef USE_ICONV @@ -670,8 +670,8 @@ sub_num=0;n_max=32; first=(subtitle *)malloc(n_max*sizeof(subtitle)); - if(!first) return NULL; - + if(!first) { fclose(fd); return NULL; } + while(1){ subtitle *sub; if(sub_num>=n_max){ @@ -749,11 +749,11 @@ if ( fname == NULL ) return NULL; - + sub_name1=strrchr(fname,'.'); if (!sub_name1) return NULL; pos=sub_name1-fname; - + sub_name1=malloc(strlen(fname)+8); strcpy(sub_name1,fname); @@ -762,17 +762,17 @@ sprintf (sub_name2, "%s%s", path, tmp+1); else sprintf (sub_name2, "%s%s", path, fname); - + aviptr1=strrchr(sub_name1,'.'); aviptr2=strrchr(sub_name2,'.'); - + for(j=0;j<=1;j++){ char* sub_name=j?sub_name1:sub_name2; #ifdef USE_ICONV for ( i=(sub_cp?2:0);i<(sizeof(sub_exts)/sizeof(char*));i++ ) { #else for ( i=0;i<(sizeof(sub_exts)/sizeof(char*));i++ ) { -#endif +#endif strcpy(j?aviptr1:aviptr2,sub_exts[i]); if((f=fopen( sub_name,"rt" ))) { fclose( f ); @@ -782,7 +782,8 @@ } } } - + free(sub_name1); + free(sub_name2); return NULL; } Modified: mplayerxp/vobsub.c =================================================================== --- mplayerxp/vobsub.c 2009-12-16 15:56:00 UTC (rev 43) +++ mplayerxp/vobsub.c 2009-12-16 17:30:20 UTC (rev 44) @@ -100,8 +100,10 @@ if (err) close(fd); } - if (err) + else { free(res); + close(fd); + } } return err ? NULL : res; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |