From e0e100a8a43ed39f2d1e662e73ba6586619db43d Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 6 Dec 2024 18:00:32 +0100 Subject: [PATCH] added checking for NULL pointer for UTF-8 conversion functions --- src/libgame/misc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 40e76611..2bd443a2 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -2304,6 +2304,9 @@ void WriteUnusedBytesToFile(FILE *file, unsigned int bytes) char *getUTF8FromLatin1(char *latin1) { + if (latin1 == NULL) + return NULL; + int max_utf8_size = 2 * strlen(latin1) + 1; char *utf8 = checked_calloc(max_utf8_size); unsigned char *src = (unsigned char *)latin1; @@ -2336,6 +2339,9 @@ char *getUTF8FromLatin1(char *latin1) char *getLatin1FromUTF8(char *utf8) { + if (utf8 == NULL) + return NULL; + int max_latin1_size = strlen(utf8) + 1; char *latin1 = checked_calloc(max_latin1_size); unsigned char *src = (unsigned char *)utf8; -- 2.34.1