/*
* Trim the final ", "
*/
- MEM(list = talloc_bstr_realloc(NULL, list, talloc_array_length(list) - 3));
+ MEM(list = talloc_bstr_realloc(NULL, list, talloc_array_length(list) - 2));
cf_log_err(cp, "Invalid value \"%s\". Expected one of %s", cf_pair_value(cp), list);
char *n;
if (!in) {
- n = talloc_array(ctx, char, inlen);
+ n = talloc_array(ctx, char, inlen + 1);
n[0] = '\0';
return n;
}
rest_read_t func, size_t limit, void *userdata)
{
char *buff = NULL;
- size_t alloc = REST_BODY_ALLOC_CHUNK; /* Size of buffer to alloc */
+ size_t needed = REST_BODY_ALLOC_CHUNK; /* Size of buffer to alloc */
size_t used = 0; /* Size of data written */
size_t len = 0;
- buff = talloc_array(NULL, char, alloc);
+ buff = talloc_array(NULL, char, needed);
for (;;) {
- len = func(buff + used, alloc - used, 1, userdata);
+ len = func(buff + used, needed - used, 1, userdata);
used += len;
if (!len) {
*out = buff;
return used;
}
- alloc = alloc * 2;
- if (alloc > limit) break;
+ needed *= 2;
+ if (needed > limit) break;
- MEM(buff = talloc_realloc(NULL, buff, char, alloc));
+ MEM(buff = talloc_realloc(NULL, buff, char, needed));
}
talloc_free(buff);