Skip to content

Commit a14f8ea

Browse files
DragonsAshesSebastien Foucherrmalmain
authored
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 <[email protected]> Co-authored-by: Romain Malmain <[email protected]>
1 parent 3ebc96e commit a14f8ea

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

io/channel-buffer.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ qio_channel_buffer_new(size_t capacity)
3535
if (capacity) {
3636
ioc->data = g_new0(uint8_t, capacity);
3737
ioc->capacity = capacity;
38-
39-
//// --- Begin LibAFL code ---
40-
ioc->internal_allocation = true;
41-
//// --- End LibAFL code ---
4238
}
4339

40+
//// --- Begin LibAFL code ---
41+
ioc->internal_allocation = capacity > 0;
42+
//// --- End LibAFL code ---
43+
4444
return ioc;
4545
}
4646

@@ -75,6 +75,7 @@ static void qio_channel_buffer_finalize(Object *obj)
7575
g_free(ioc->data);
7676
}
7777

78+
ioc->data = NULL;
7879
//// --- End LibAFL code ---
7980
// g_free(ioc->data);
8081

@@ -181,8 +182,8 @@ static int qio_channel_buffer_close(QIOChannel *ioc,
181182
g_free(bioc->data);
182183
}
183184

184-
//g_free(bioc->data);
185185
//// --- End LibAFL code ---
186+
//g_free(bioc->data);
186187
bioc->data = NULL;
187188
bioc->capacity = bioc->usage = bioc->offset = 0;
188189

libafl/syx-snapshot/device-save.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ void device_restore_all(DeviceSaveState* dss) {
9999

100100
libafl_restoring_devices = save_libafl_restoring_devices;
101101

102+
object_unref(OBJECT(bioc));
102103
qemu_fclose(f);
103104
}
104105

0 commit comments

Comments
 (0)