From 44d68e19d72745cadb53c02b897b9994f70ca214 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 19 Jul 2014 16:24:01 +0200 Subject: [PATCH] support empty strings --- src/nestegg.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/nestegg.c b/src/nestegg.c index 54dc330..fee559f 100644 --- a/src/nestegg.c +++ b/src/nestegg.c @@ -730,14 +730,16 @@ ne_read_string(nestegg * ctx, char ** val, uint64_t length) char * str; int r; - if (length == 0 || length > LIMIT_STRING) + if (length > LIMIT_STRING) return -1; str = ne_pool_alloc(length + 1, ctx->alloc_pool); if (!str) return -1; - r = ne_io_read(ctx->io, (unsigned char *) str, length); - if (r != 1) - return r; + if (length) { + r = ne_io_read(ctx->io, (unsigned char *) str, length); + if (r != 1) + return r; + } str[length] = '\0'; *val = str; return 1;