From df0aeac4a893a641fd167516ad2831ddd3ddda1e Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Tue, 1 Jul 2014 07:54:07 +0000 Subject: [PATCH] free the correct file. move the get_data_and_size out of the loop git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15049 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/kodak/dc120/library.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/camlibs/kodak/dc120/library.c b/camlibs/kodak/dc120/library.c index e3b92b733..a592e06ef 100644 --- a/camlibs/kodak/dc120/library.c +++ b/camlibs/kodak/dc120/library.c @@ -451,13 +451,15 @@ static int dc120_get_file_preview (Camera *camera, CameraFile *file, int file_nu /* Create a file for KDC data */ gp_file_new(&f); if (dc120_packet_read_data(camera, f, cmd_packet, size, 1024, context)==GP_ERROR) { - gp_file_free(file); + gp_file_free(f); return (GP_ERROR); } /* Convert to PPM file for now */ gp_file_append(file, "P3\n80 60\n255\n", 13); + + gp_file_get_data_and_size (f, &f_data, &f_size); + for (x=0; x<14400; x+=3) { - gp_file_get_data_and_size (f, &f_data, &f_size); sprintf(buf, "%i %i %i\n", (unsigned char)f_data[x+1280], (unsigned char)f_data[x+1281], @@ -465,7 +467,7 @@ static int dc120_get_file_preview (Camera *camera, CameraFile *file, int file_nu gp_file_append(file, buf, strlen(buf)); } - sleep(1); + sleep(1); /* FIXME: why? */ return (GP_OK); }