Memory leak and unhandled out of memory case.
authorEdouard Tisserant <edouard@pep-project.org>
Fri, 06 Jan 2017 10:23:51 +0100
changeset 152775d56a822caa
parent 1526 fd344589f32b
child 1528 f0ed0f1f2b56
child 1533 ca90b6245a51
child 1535 3efb259b8d2c
Memory leak and unhandled out of memory case.
src/sync_impl.c
     1.1 --- a/src/sync_impl.c	Fri Jan 06 09:16:10 2017 +0100
     1.2 +++ b/src/sync_impl.c	Fri Jan 06 10:23:51 2017 +0100
     1.3 @@ -290,14 +290,19 @@
     1.4  
     1.5                  // detect and mitigate address spoofing
     1.6                  Identity check_me = NULL;
     1.7 -                const char* null_terminated_address = 
     1.8 +                char* null_terminated_address = 
     1.9                      strndup((char *) msg->header.me.address->buf,
    1.10                              msg->header.me.address->size);
    1.11  
    1.12 -                status = get_identity(session, 
    1.13 -                                      null_terminated_address, 
    1.14 -                                      PEP_OWN_USERID, 
    1.15 -                                      &check_me);
    1.16 +                if(null_terminated_address){
    1.17 +                    status = get_identity(session, 
    1.18 +                                          null_terminated_address, 
    1.19 +                                          PEP_OWN_USERID, 
    1.20 +                                          &check_me);
    1.21 +                    free(null_terminated_address);
    1.22 +                } 
    1.23 +                else
    1.24 +                    status = PEP_OUT_OF_MEMORY;
    1.25  
    1.26                  if (status == PEP_OUT_OF_MEMORY)
    1.27                      goto free_all;