fix for the case of max_sz == 0
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1650 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -90,7 +90,10 @@ as_reserve (struct state *state, size_t n)
|
|||||||
if (state->max_sz && state->sz >= state->max_sz)
|
if (state->max_sz && state->sz >= state->max_sz)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
state->sz = min(state->max_sz, state->sz*2);
|
if (state->max_sz)
|
||||||
|
state->sz = min(state->max_sz, state->sz*2);
|
||||||
|
else
|
||||||
|
state->sz *= 2;
|
||||||
tmp = realloc (state->str, state->sz);
|
tmp = realloc (state->str, state->sz);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -448,7 +451,10 @@ vasnprintf (char **ret, size_t max_sz, const char *format, va_list args)
|
|||||||
struct state state;
|
struct state state;
|
||||||
|
|
||||||
state.max_sz = max_sz;
|
state.max_sz = max_sz;
|
||||||
state.sz = min(1, max_sz);
|
if (max_sz)
|
||||||
|
state.sz = min(1, max_sz);
|
||||||
|
else
|
||||||
|
state.sz = 1;
|
||||||
state.str = malloc(state.sz);
|
state.str = malloc(state.sz);
|
||||||
if (state.str == NULL) {
|
if (state.str == NULL) {
|
||||||
*ret = NULL;
|
*ret = NULL;
|
||||||
|
Reference in New Issue
Block a user