diff --git a/libgphoto2/gphoto2-list.c b/libgphoto2/gphoto2-list.c index 4558db909..4edcc46df 100644 --- a/libgphoto2/gphoto2-list.c +++ b/libgphoto2/gphoto2-list.c @@ -143,11 +143,10 @@ gp_list_unref (CameraList *list) { CHECK_LIST (list); - list->ref_count--; - - if (!list->ref_count) + if (list->ref_count == 1) /* time to free */ gp_list_free (list); - + else + list->ref_count--; return (GP_OK); }