mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-28 00:00:18 +05:30
C: reverse-ramdisk.c: tf_free
: prevent memory leaks
This commit is contained in:
parent
bae1b1a301
commit
3e37f5fb73
@ -170,11 +170,13 @@ int tf_free(int ID) {
|
|||||||
// Reallocate memory for the temp_files array
|
// Reallocate memory for the temp_files array
|
||||||
if (--num_temp_files > 0) {
|
if (--num_temp_files > 0) {
|
||||||
DBG_PRINT("num_temp_files = %zu\n", num_temp_files);
|
DBG_PRINT("num_temp_files = %zu\n", num_temp_files);
|
||||||
if ((temp_files = realloc(temp_files, num_temp_files
|
TempFile* new_temp_files_ptr = realloc(temp_files, num_temp_files *
|
||||||
* sizeof(TempFile))) == NULL) {
|
sizeof(TempFile));
|
||||||
LINE_FAIL(-2);
|
if (new_temp_files_ptr == NULL) {
|
||||||
|
LINE_FAIL(-3);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
temp_files = new_temp_files_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_files[index].locked = false;
|
temp_files[index].locked = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user