From 0def3a83a6b533ee700673933f63d4280c1f53ce Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Sat, 9 Nov 2024 00:47:00 +0100 Subject: [PATCH] In `gp_file_set_data_and_size` free `file->data` only if allocated --- libgphoto2/gphoto2-file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgphoto2/gphoto2-file.c b/libgphoto2/gphoto2-file.c index 04d4d5e3e..e39874df4 100644 --- a/libgphoto2/gphoto2-file.c +++ b/libgphoto2/gphoto2-file.c @@ -320,7 +320,7 @@ gp_file_set_data_and_size (CameraFile *file, char *data, switch (file->accesstype) { case GP_FILE_ACCESSTYPE_MEMORY: - free (file->data); + if (file->data) free (file->data); file->data = (unsigned char*)data; file->size = size; break;