Mercurial > libdvdnav.hg
comparison dvdread/dvd_reader.c @ 328:727b18c5824b src
malloc() a buffer large enough before calling getcwd() - part of ogle-1778
author | nicodvb |
---|---|
date | Mon, 31 Dec 2007 18:08:06 +0000 |
parents | d0a19ce1aa3d |
children | 071927ab5357 |
comparison
equal
deleted
inserted
replaced
327:d0a19ce1aa3d | 328:727b18c5824b |
---|---|
416 char *new_path; | 416 char *new_path; |
417 int cdir = open( ".", O_RDONLY ); | 417 int cdir = open( ".", O_RDONLY ); |
418 | 418 |
419 if( cdir >= 0 ) { | 419 if( cdir >= 0 ) { |
420 chdir( path_copy ); | 420 chdir( path_copy ); |
421 new_path = getcwd( NULL, PATH_MAX ); | 421 new_path = malloc(PATH_MAX+1); |
422 if(!new_path) { | |
423 free(path); | |
424 return NULL; | |
425 } | |
426 getcwd(new_path, PATH_MAX ); | |
422 fchdir( cdir ); | 427 fchdir( cdir ); |
423 close( cdir ); | 428 close( cdir ); |
424 if( new_path ) { | |
425 free( path_copy ); | 429 free( path_copy ); |
426 path_copy = new_path; | 430 path_copy = new_path; |
427 } | |
428 } | 431 } |
429 } | 432 } |
430 #endif | 433 #endif |
431 /** | 434 /** |
432 * If we're being asked to open a directory, check if that directory | 435 * If we're being asked to open a directory, check if that directory |