Commit e9dc4f79 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont Committed by Jean-Baptiste Kempf

vcd: fix NULL dereference on error

(cherry picked from commit a1c81a10276b3839c9832d274ae5def3c53ee203)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent f97a4cf8
...@@ -782,30 +782,33 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev, ...@@ -782,30 +782,33 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
{ {
/* psz_dev must be the cue file. Let's assume there's a .bin /* psz_dev must be the cue file. Let's assume there's a .bin
* file with the same filename */ * file with the same filename */
psz_vcdfile = malloc( p_pos - psz_dev + 5 /* ".bin" */ ); if( asprintf( &psz_vcdfile, "%.*s.bin", (int)(p_pos - psz_dev),
strncpy( psz_vcdfile, psz_dev, p_pos - psz_dev ); psz_dev ) < 0 )
strcpy( psz_vcdfile + (p_pos - psz_dev), ".bin"); psz_vcdfile = NULL;
psz_cuefile = strdup( psz_dev ); psz_cuefile = strdup( psz_dev );
} }
else else
if( p_pos )
{ {
/* psz_dev must be the actual vcd file. Let's assume there's a .cue /* psz_dev must be the actual vcd file. Let's assume there's a .cue
* file with the same filename */ * file with the same filename */
if( p_pos ) if( asprintf( &psz_cuefile, "%.*s.cue", (int)(p_pos - psz_dev),
{ psz_dev ) < 0 )
psz_cuefile = malloc( p_pos - psz_dev + 5 /* ".cue" */ ); psz_cuefile = NULL;
strncpy( psz_cuefile, psz_dev, p_pos - psz_dev ); psz_vcdfile = strdup( psz_dev );
strcpy( psz_cuefile + (p_pos - psz_dev), ".cue");
} }
else else
{ {
if( asprintf( &psz_cuefile, "%s.cue", psz_dev ) == -1 ) if( asprintf( &psz_cuefile, "%s.cue", psz_dev ) == -1 )
psz_cuefile = NULL; psz_cuefile = NULL;
} /* If we need to look up the .cue file, then we don't have to look
/* If we need to look up the .cue file, then we don't have to look for the vcd */ * for the vcd */
psz_vcdfile = strdup( psz_dev ); psz_vcdfile = strdup( psz_dev );
} }
if( psz_cuefile == NULL || psz_vcdfile == NULL )
goto error;
/* Open the cue file and try to parse it */ /* Open the cue file and try to parse it */
msg_Dbg( p_this,"trying .cue file: %s", psz_cuefile ); msg_Dbg( p_this,"trying .cue file: %s", psz_cuefile );
cuefile = vlc_fopen( psz_cuefile, "rt" ); cuefile = vlc_fopen( psz_cuefile, "rt" );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment