projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f859dfe
)
added checking for NULL pointer for UTF-8 conversion functions
author
Holger Schemel
<holger.schemel@virtion.de>
Fri, 6 Dec 2024 17:00:32 +0000
(18:00 +0100)
committer
Holger Schemel
<holger.schemel@virtion.de>
Fri, 6 Dec 2024 12:04:26 +0000
(13:04 +0100)
src/libgame/misc.c
patch
|
blob
|
history
diff --git
a/src/libgame/misc.c
b/src/libgame/misc.c
index 40e766113b18a12fb5a40574df0b041397cfdd6c..2bd443a22dd6e8ee985b0f9fdb7e2bea1274838b 100644
(file)
--- 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;