Re: libdvdread: Patch OK?
Hi!
On Mon, 2011-09-05 at 15:32:10 +0200, Svante Signell wrote:
> Attached is a modified version of your patch also taking Samuels
> comments into account. Probably still not completely OK?
> --- ./libdvdread-4.1.4-1219/src/dvd_reader.c 2010-07-31 02:10:28.000000000 +0200
> +++ ./libdvdread-4.1.4-1219.modified/src/dvd_reader.c 2011-09-05 15:20:53.000000000 +0200
> @@ -625,17 +632,19 @@
[...]
> -static int findDirFile( const char *path, const char *file, char *filename )
> +static int findDirFile( const char *path, const char *file, char **filename )
[...]
> while( ( ent = readdir( dir ) ) != NULL ) {
> if( !strcasecmp( ent->d_name, file ) ) {
> - sprintf( filename, "%s%s%s", path,
> + *filename = malloc( strlen( path ) + 1 + strlen( ent->d_name ) + 1 );
> + sprintf( *filename, "%s%s%s", path,
> @@ -646,9 +655,9 @@
[...]
> -static int findDVDFile( dvd_reader_t *dvd, const char *file, char *filename )
> +static int findDVDFile( dvd_reader_t *dvd, const char *file, char **filename )
[...]
> + video_path = malloc( strlen( dvd->path_root ) + 10 + 1 );
> sprintf( video_path, "%s/VIDEO_TS/", dvd->path_root );
malloc might fail on those two cases, the return value should be checked.
regards,
guillem
Reply to: