support empty strings
This commit is contained in:
parent
142e478c51
commit
44d68e19d7
1 changed files with 6 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue