summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/dynstr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/dynstr.c b/lib/dynstr.c
index 44c4b56..9c91b90 100644
--- a/lib/dynstr.c
+++ b/lib/dynstr.c
@@ -384,7 +384,9 @@ static Dynstr *read_helper(size_t (*callback)(FILE *f, int fd, unsigned char *bu
n = callback(f, fd, dynstr->mem, size);
if (n == DYNSTR_ERROR) {
+ int saved = errno;
dynstr_free(dynstr);
+ errno = saved;
return NULL;
}
@@ -449,6 +451,7 @@ static Dynstr *readline_helper(int (*callback)(FILE *, int), FILE *f, int fd)
int c;
unsigned char buf[1024];
size_t buflen;
+ int saved;
line = dynstr_new_empty();
buflen = 0;
@@ -496,9 +499,11 @@ static Dynstr *readline_helper(int (*callback)(FILE *, int), FILE *f, int fd)
return line;
error:
+ saved = errno;
dynstr_free(line);
dynstr_free(temp1);
dynstr_free(temp2);
+ errno = saved;
return NULL;
}