forked from lda/telodendria
Fix a write-out-of-bounds error in Json.
This commit is contained in:
parent
3bbff5379f
commit
9e9b5c9cda
2 changed files with 29 additions and 15 deletions
14
src/Json.c
14
src/Json.c
|
@ -424,6 +424,20 @@ JsonDecodeString(FILE * in)
|
|||
switch (c)
|
||||
{
|
||||
case '"':
|
||||
if (len >= allocated)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
allocated += 1;
|
||||
tmp = Realloc(str, allocated * sizeof(char));
|
||||
if (!tmp)
|
||||
{
|
||||
Free(str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
str = tmp;
|
||||
}
|
||||
str[len] = '\0';
|
||||
return str;
|
||||
break;
|
||||
|
|
|
@ -80,6 +80,21 @@ const char
|
|||
"======================================================="
|
||||
};
|
||||
|
||||
static void
|
||||
TelodendriaHexDump(size_t off, char *hexBuf, char *asciiBuf, void *args)
|
||||
{
|
||||
LogConfig *lc = args;
|
||||
|
||||
if (hexBuf && asciiBuf)
|
||||
{
|
||||
Log(lc, LOG_DEBUG, "%04x: %s | %s |", off, hexBuf, asciiBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lc, LOG_DEBUG, "%04x", off);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
TelodendriaMemoryHook(MemoryAction a, MemoryInfo * i, void *args)
|
||||
{
|
||||
|
@ -112,21 +127,6 @@ TelodendriaMemoryHook(MemoryAction a, MemoryInfo * i, void *args)
|
|||
MemoryInfoGetPointer(i));
|
||||
}
|
||||
|
||||
static void
|
||||
TelodendriaHexDump(size_t off, char *hexBuf, char *asciiBuf, void *args)
|
||||
{
|
||||
LogConfig *lc = args;
|
||||
|
||||
if (hexBuf && asciiBuf)
|
||||
{
|
||||
Log(lc, LOG_DEBUG, "%04x: %s | %s |", off, hexBuf, asciiBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(lc, LOG_DEBUG, "%04x", off);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
TelodendriaMemoryIterator(MemoryInfo * i, void *args)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue