check for failure on realloc

This commit is contained in:
Chris Cromer 2021-07-07 00:00:31 -04:00
parent b9b6d60aff
commit 2d6303e311

View File

@ -30,6 +30,10 @@ static CleanArray clean;
*/
void add_to_cleanup(void *data) {
clean.array = realloc(clean.array, (clean.size + 1) * sizeof(void *));
if (clean.array == NULL) {
perror("realloc");
exit(EXIT_FAILURE);
}
clean.array[clean.size++] = data;
}