summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Harms <wharms@bfs.de>2024-01-08 16:50:52 +0100
committerWalter Harms <wharms@bfs.de>2024-01-08 16:50:52 +0100
commit4f78b615806fa1cfe2bdcf3f7c868b8a00dede77 (patch)
treed3b8b680339b60d944d9361cc13e75e090c13639
parented0b97e480d7d07c24719007273989b2eb3e4046 (diff)
Fix XCreateIC() memory leak (Part 2)
Direct leak of 12 byte(s) in 2 object(s) allocated from: #0 0x7f4f25c3f7a7 in strdup (/usr/lib64/libasan.so.6+0x5c7a7) #1 0x7f4f252ce6a1 in _XimEncodeString libX11-1.8.3/modules/im/ximcp/imRm.c:818 #2 0x7f4f252ce6a1 in _XimEncodeString libX11-1.8.3/modules/im/ximcp/imRm.c:807 #3 0x7f4f252d2f0f in _XimSetICValueData libX11-1.8.3/modules/im/ximcp/imRm.c:2912 #4 0x7f4f252b536a in _XimLocalCreateIC libX11-1.8.3/modules/im/ximcp/imLcIc.c:176 #5 0x7f4f251f0105 in XCreateIC libX11-1.8.3/src/xlibi18n/ICWrap.c:251 detected and fix by Patrick Lerda <patrick9876@free.fr> applied with adjustment, do changes when OOM (unlikely but good practise)
-rw-r--r--modules/im/ximcp/imRm.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/modules/im/ximcp/imRm.c b/modules/im/ximcp/imRm.c
index 9f5b99bc..5dec292d 100644
--- a/modules/im/ximcp/imRm.c
+++ b/modules/im/ximcp/imRm.c
@@ -510,13 +510,21 @@ _XimDefaultResName(
Xic ic = (Xic)parm;
Xim im = (Xim)ic->core.im;
char **out;
-
+ char *string;
+
if(im->core.res_name == (char *)NULL) {
return True;
}
+ string=strdup(im->core.res_name);
+ if ( string == NULL)
+ return False;
+
out = (char **)((char *)top + info->offset);
- *out = im->core.res_name;
+
+ Xfree(*out); /* free old im->core.res_name */
+ *out =string;
+
return True;
}
@@ -529,14 +537,22 @@ _XimDefaultResClass(
{
Xic ic = (Xic)parm;
Xim im = (Xim)ic->core.im;
+ char *string;
char **out;
if(im->core.res_class == (char *)NULL) {
return True;
}
+ string=strdup(im->core.res_class);
+ if (string == NULL)
+ return False;
+
out = (char **)((char *)top + info->offset);
- *out = im->core.res_class;
+
+ Xfree(*out); /* free old im->core.res_class */
+ *out = string;
+
return True;
}