]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/blobdiff - src/trackfds.h
Add more error checks.
[coloredstderr/coloredstderr.git] / src / trackfds.h
index b9089bbd25b0444772c6442ca27dedd3ac7e4334..00b3b6e3b55da47e7c66453e609e6b7754a6071d 100644 (file)
@@ -169,7 +169,7 @@ static char *update_environment_buffer_entry(char *x, int fd) {
     assert(fd >= 0);
 
     int length = snprintf(x, 10 + 1, "%d", fd);
-    if (length >= 10 + 1) {
+    if (length >= 10 + 1 || length <= 0 /* shouldn't happen */) {
         /* Integer too big to fit the buffer, skip it. */
 #ifdef WARNING
         warning("update_environment_buffer_entry(): truncated fd: %d [%d]\n",
@@ -325,7 +325,7 @@ static int tracked_fds_find_slow(int fd) noinline;
  * they are not called often enough.
  */
 inline static int tracked_fds_find(int fd) always_inline;
-static int tracked_fds_find(int fd) {
+inline static int tracked_fds_find(int fd) {
     assert(fd >= 0);
 
     if (fd < TRACKFDS_STATIC_COUNT) {