diff --git a/ChangeLog b/ChangeLog index 88c994669..fe6222a17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-08-19 Lutz Müller + + * libgphoto2/filesys.c (gp_filesystem_format): Fix bug found by + Stéphane Castejon. + 2001-08-19 Lutz Müller * libgphoto2/globals.h: Unused. Removed. diff --git a/libgphoto2/filesys.c b/libgphoto2/filesys.c index ac038c386..74fe9ae98 100644 --- a/libgphoto2/filesys.c +++ b/libgphoto2/filesys.c @@ -330,15 +330,16 @@ gp_filesystem_format (CameraFilesystem *fs) { int x, y; - if (fs->folder) { - for (x = 0; x < fs->count; x++) { - for (y=0; yfolder[x]->count; y++) - free (fs->folder[x]->file[y]); - free (fs->folder[x]); - } - free (fs->folder); - } - fs->count = 0; + if (!fs) + return (GP_ERROR_BAD_PARAMETERS); + + for (x = 0; x < fs->count; x++) { + for (y = 0; y < fs->folder[x]->count; y++) + free (fs->folder[x]->file[y]); + free (fs->folder[x]); + } + free (fs->folder); + fs->count = 0; return (GP_OK); }