Fix a memory bug in StrRandom() with RandIntN().

We're storing integers in this buffer, so we have to allocate enough
memory for them. An integer is usually more than one byte.
This commit is contained in:
Jordan Bancino 2023-02-16 13:10:09 +00:00
parent 38438c297e
commit c78dc3bd31
2 changed files with 2 additions and 2 deletions

View file

@ -171,7 +171,7 @@ StrRandom(size_t len)
return NULL; return NULL;
} }
nums = Malloc(len); nums = Malloc(len * sizeof(int));
if (!nums) if (!nums)
{ {
Free(str); Free(str);

View file

@ -36,7 +36,7 @@ CFLAGS="${CFLAGS} ${DEFINES} ${INCLUDES}"
LDFLAGS="${LDFLAGS} ${STATIC}" LDFLAGS="${LDFLAGS} ${STATIC}"
if [ "$DEBUG" = "1" ]; then if [ "$DEBUG" = "1" ]; then
CFLAGS="$CFLAGS -O0 -g" CFLAGS="$CFLAGS -O0 -g -pg"
LDFLAGS="-lm -pthread -v" LDFLAGS="-lm -pthread -v"
PROG="$PROG-debug" PROG="$PROG-debug"
fi fi