[PATCH libICE 08/13] add check for malloc
walter harms
wharms at bfs.de
Wed Oct 18 16:02:26 UTC 2017
add check for malloc
fix a potential null pointer deference error and
release already allocated memory
Signed-off-by: Walter Harms <wharms at bfs.de>
---
src/setauth.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/setauth.c b/src/setauth.c
index 1017b02..1f3e5cc 100644
--- a/src/setauth.c
+++ b/src/setauth.c
@@ -102,6 +102,19 @@ IceSetPaAuthData (
entries[i].auth_data_length;
_IcePaAuthDataEntries[j].auth_data = malloc (
entries[i].auth_data_length);
+ if (! _IcePaAuthDataEntries[j].auth_data)
+ {
+ /*
+ we can not inform the user about a botched update
+ but we can release the memory we already have
+ */
+
+ free(_IcePaAuthDataEntries[j].protocol_name);
+ free(_IcePaAuthDataEntries[j].network_id);
+ free(_IcePaAuthDataEntries[j].auth_name);
+ _IcePaAuthDataEntries[j].auth_data_length = 0;
+ return;
+ }
memcpy (_IcePaAuthDataEntries[j].auth_data,
entries[i].auth_data, entries[i].auth_data_length);
}
--
2.1.4
More information about the xorg-devel
mailing list