Skip to content

Commit 48b6206

Browse files
committed
kdb char arrays aren't null terminated
1 parent 2dfbd67 commit 48b6206

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/mqtt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ static char* getCharArrayAsStringFromList(K propValues,int row, const char** val
5656
if ((int)(kK(propValues)[row]->t) == KC)
5757
{
5858
// Don't use strndup because it's not supported on early OS X builds
59-
char* str = malloc(kK(propValues)[row]->n);
59+
char* str = malloc(kK(propValues)[row]->n + 1);
6060
memcpy(str, kC(kK(propValues)[row]), kK(propValues)[row]->n);
61+
str[kK(propValues)[row]->n] = '\0';
6162
*value = str;
6263
return 0;
6364
}

0 commit comments

Comments
 (0)