changeset 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
files dvdread/dvd_reader.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dvdread/dvd_reader.c	Mon Dec 31 17:56:30 2007 +0000
+++ b/dvdread/dvd_reader.c	Mon Dec 31 18:08:06 2007 +0000
@@ -418,13 +418,16 @@
 	    
 	    if( cdir >= 0 ) {
 		chdir( path_copy );
-		new_path = getcwd( NULL, PATH_MAX );
+		new_path = malloc(PATH_MAX+1);
+		if(!new_path) {
+		  free(path);
+		  return NULL;
+		}
+		getcwd(new_path, PATH_MAX );
 		fchdir( cdir );
 		close( cdir );
-		if( new_path ) {
 		    free( path_copy );
 		    path_copy = new_path;
-		}
 	    }
 	}
 #endif