summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-01-12 12:18:31 +0000
committerLars Wirzenius <liw@liw.fi>2013-01-12 12:18:31 +0000
commit535dbc6de645765adea8bd7092daf92a06f6057a (patch)
tree34dfa1345f40c07bef48b1c988dd7a03fc16f36b /lib
parentdae1501f9f33bf26d2fda623dec2daa31fc68485 (diff)
downloaddynstr-535dbc6de645765adea8bd7092daf92a06f6057a.tar.gz
Preserve errno when returning errorHEADmaster
Reported-By: Russ Allbery
Diffstat (limited to 'lib')
-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;
}