From: Simon Ruderich Date: Tue, 4 Jun 2013 22:57:26 +0000 (+0200) Subject: trackfds.h: Fix realloc() in update_environment(). X-Git-Tag: 0.1~113 X-Git-Url: https://ruderich.org/simon/gitweb/?p=coloredstderr%2Fcoloredstderr.git;a=commitdiff_plain;h=76742316e873c787c96cb57c36fb432148b13240 trackfds.h: Fix realloc() in update_environment(). --- diff --git a/src/trackfds.h b/src/trackfds.h index 3577fd6..34f0b1d 100644 --- a/src/trackfds.h +++ b/src/trackfds.h @@ -161,7 +161,8 @@ static void update_environment(void) { static void tracked_fds_add(int fd) { if (tracked_fds_count >= tracked_fds_space) { size_t new_space = tracked_fds_space + TRACKFDS_REALLOC_STEP; - if (!realloc(tracked_fds, sizeof(*tracked_fds) * new_space)) { + int *tmp = realloc(tracked_fds, sizeof(*tracked_fds) * new_space); + if (!tmp) { /* We can do nothing, just ignore the error. We made sure not to * destroy our state, so the new descriptor is ignored without any * other consequences. */ @@ -171,6 +172,7 @@ static void tracked_fds_add(int fd) { #endif return; } + tracked_fds = tmp; tracked_fds_space = new_space; }