summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2012-11-29 13:30:03 +0000
committerKeith Bostic <keith@wiredtiger.com>2012-11-29 13:30:03 +0000
commit436bf30de09aa5475b692f81a47ffdafc7bd93dd (patch)
tree31a66297469eb5d6c514205e73958b27fcf74829
parent8bae6ba2075088e12f4592bd16b01e96d49b60fb (diff)
downloadmongo-436bf30de09aa5475b692f81a47ffdafc7bd93dd.tar.gz
Don't drop core if the line (a value) has no contents.
-rw-r--r--src/utilities/util_misc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/utilities/util_misc.c b/src/utilities/util_misc.c
index 473a87588f0..bd1df294bbe 100644
--- a/src/utilities/util_misc.c
+++ b/src/utilities/util_misc.c
@@ -50,6 +50,11 @@ util_read_line(ULINE *l, int eof_expected, int *eofp)
++line;
*eofp = 0;
+ if (l->memsize == 0) {
+ if ((l->mem = realloc(l->mem, l->memsize + 1024)) == NULL)
+ return (util_err(errno, NULL));
+ l->memsize = 1024;
+ }
for (len = 0;; ++len) {
if ((ch = getchar()) == EOF) {
if (len == 0) {
@@ -70,7 +75,7 @@ util_read_line(ULINE *l, int eof_expected, int *eofp)
* line into a record number, that means we always need one
* extra byte at the end.
*/
- if (l->memsize == 0 || len >= l->memsize - 1) {
+ if (len >= l->memsize - 1) {
if ((l->mem =
realloc(l->mem, l->memsize + 1024)) == NULL)
return (util_err(errno, NULL));