X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Ftrackfds.h;h=476093818a5dae4aabe2b1c1e50c7680124e18a1;hb=a9db9083b6fd9c1bd6a09df6d64386d806488f7c;hp=3577fd6323cbaef8d30150f1737362bc7deff4f9;hpb=d475e5ec892390e3f43c5fb4cb373cedc33211fd;p=coloredstderr%2Fcoloredstderr.git diff --git a/src/trackfds.h b/src/trackfds.h index 3577fd6..4760938 100644 --- a/src/trackfds.h +++ b/src/trackfds.h @@ -138,7 +138,7 @@ static void update_environment(void) { for (i = 0; i < tracked_fds_count; i++) { int length = snprintf(x, 10 + 1, "%d", tracked_fds[i]); if (length >= 10 + 1) { - /* Integer too bit to fit the buffer, skip it. */ + /* Integer too big to fit the buffer, skip it. */ continue; } @@ -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; }