On 18 October 2017 at 16:54, walter harms <[email protected]> wrote: > > check the return of malloc() > > Signed-off-by: Walter Harms <[email protected]> > --- > src/protosetup.c | 21 +++++++++++++++------ > 1 file changed, 15 insertions(+), 6 deletions(-) > > diff --git a/src/protosetup.c b/src/protosetup.c > index b6aece8..dbc136e 100644 > --- a/src/protosetup.c > +++ b/src/protosetup.c > @@ -110,11 +110,17 @@ IceProtocolSetup ( > /* > * Generate the message. > */ > + authCount = 0; > + authIndices = NULL; > > if (myProtocol->orig_client->auth_count > 0) > { > authIndices = malloc ( > myProtocol->orig_client->auth_count * sizeof (int)); > + if (! authIndices) { I know the existing coding style is iffy, but please don't diverge even more. Namely - no space between ! and authIndices (same applies below).
> + strncpy (errorStringRet,"out of memory",errorLength); Space after the comma. ... > + free(iceConn->protosetup_to_you); > + free(authIndices); > strncpy (errorStringRet, > "IO error occured doing Protocol Setup on connection", > errorLength); > @@ -240,6 +249,7 @@ IceProtocolSetup ( > free (iceConn->protosetup_to_you->my_auth_indices); > free (iceConn->protosetup_to_you); > iceConn->protosetup_to_you = NULL; > + free(authIndices); > } > } > > @@ -279,6 +289,5 @@ IceProtocolSetup ( > versionRec->process_msg_proc; > > return (IceProtocolSetupSuccess); > - > These seem to be unrelated memory leak/whitespace fixes. Please keep that as separate commit. -Emil _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
