Unset object to free memory space allocated (memory leak) (#72)

* Unset object to free memory space allocated (memory leak in fast snapshot implementation for libafl)

---------

Co-authored-by: Sebastien Foucher <sebastien.foucher@se.com>
Co-authored-by: Romain Malmain <romain.malmain@pm.me>
This commit is contained in:
Sebastien Foucher 2024-05-04 13:41:10 +02:00 committed by GitHub
parent 3ebc96e013
commit a14f8eae8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -35,12 +35,12 @@ qio_channel_buffer_new(size_t capacity)
if (capacity) { if (capacity) {
ioc->data = g_new0(uint8_t, capacity); ioc->data = g_new0(uint8_t, capacity);
ioc->capacity = capacity; ioc->capacity = capacity;
//// --- Begin LibAFL code ---
ioc->internal_allocation = true;
//// --- End LibAFL code ---
} }
//// --- Begin LibAFL code ---
ioc->internal_allocation = capacity > 0;
//// --- End LibAFL code ---
return ioc; return ioc;
} }
@ -75,6 +75,7 @@ static void qio_channel_buffer_finalize(Object *obj)
g_free(ioc->data); g_free(ioc->data);
} }
ioc->data = NULL;
//// --- End LibAFL code --- //// --- End LibAFL code ---
// g_free(ioc->data); // g_free(ioc->data);
@ -181,8 +182,8 @@ static int qio_channel_buffer_close(QIOChannel *ioc,
g_free(bioc->data); g_free(bioc->data);
} }
//g_free(bioc->data);
//// --- End LibAFL code --- //// --- End LibAFL code ---
//g_free(bioc->data);
bioc->data = NULL; bioc->data = NULL;
bioc->capacity = bioc->usage = bioc->offset = 0; bioc->capacity = bioc->usage = bioc->offset = 0;

View File

@ -99,6 +99,7 @@ void device_restore_all(DeviceSaveState* dss) {
libafl_restoring_devices = save_libafl_restoring_devices; libafl_restoring_devices = save_libafl_restoring_devices;
object_unref(OBJECT(bioc));
qemu_fclose(f); qemu_fclose(f);
} }