]> granicus.if.org Git - sudo/commitdiff
Return -1 if realloc() fails.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 14 Jul 2015 20:48:04 +0000 (14:48 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 14 Jul 2015 20:48:04 +0000 (14:48 -0600)
lib/util/parseln.c

index 1b26a3dda23ab29fa76aa705ca5a49184d5e8087..55f26815bf64985f8e2e5010c8a72da2dea18b24 100644 (file)
@@ -40,7 +40,7 @@
 
 /*
  * Read a line of input, honoring line continuation chars.
- * Remove comments and strips off leading and trailing spaces.
+ * Remove comments and strip off leading and trailing spaces.
  * Returns the line length and updates the buf and bufsize pointers.
  * XXX - just use a struct w/ state, including getline buffer?
  *       could also make comment char and line continuation configurable
@@ -99,8 +99,13 @@ sudo_parseln_v1(char **bufp, size_t *bufsizep, unsigned int *lineno, FILE *fp)
                size |= size >> 16;
                size++;
            }
-           if ((tmp = realloc(*bufp, size)) == NULL)
+           if ((tmp = realloc(*bufp, size)) == NULL) {
+               sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+                   "unable to allocate memory");
+               len = -1;
+               total = 0;
                break;
+           }
            *bufp = tmp;
            *bufsizep = size;
        }