mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-27 14:50:23 +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
|
||||
if (--num_temp_files > 0) {
|
||||
DBG_PRINT("num_temp_files = %zu\n", num_temp_files);
|
||||
if ((temp_files = realloc(temp_files, num_temp_files
|
||||
* sizeof(TempFile))) == NULL) {
|
||||
LINE_FAIL(-2);
|
||||
TempFile* new_temp_files_ptr = realloc(temp_files, num_temp_files *
|
||||
sizeof(TempFile));
|
||||
if (new_temp_files_ptr == NULL) {
|
||||
LINE_FAIL(-3);
|
||||
return -1;
|
||||
}
|
||||
temp_files = new_temp_files_ptr;
|
||||
}
|
||||
|
||||
temp_files[index].locked = false;
|
||||
|
Loading…
Reference in New Issue
Block a user