(libretro-db) Fix segfault

This commit is contained in:
Higor Eurípedes 2015-06-10 16:16:00 -03:00
parent ca998b1d3e
commit 8c9408f24a

View File

@ -516,10 +516,12 @@ static struct buffer parse_string(struct buffer buff,
if (!*error)
{
size_t nmemb = is_binstr ? (value->string.len + 1) / 2 : (value->string.len + 1);
size_t count;
value->type = is_binstr ? RDT_BINARY : RDT_STRING;
value->string.len = (buff.data + buff.offset) - str_start - 1;
value->string.buff = (char*)calloc(nmemb, sizeof(char));
count = is_binstr ? (value->string.len + 1) / 2 : (value->string.len + 1);
value->string.buff = (char*)calloc(count, sizeof(char));
if (!value->string.buff)
raise_enomem(error);
@ -889,6 +891,7 @@ void libretrodb_query_free(void *q)
free(real_q->root.argv);
real_q->root.argv = NULL;
real_q->root.argc = 0;
free(real_q);
}