add check for malloc fix a potential null pointer deference error and release already allocated memory
Signed-off-by: Walter Harms <[email protected]> --- 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 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
