src/keymanagement.c
changeset 2574 f2e0646c4b0d
parent 2552 09d77d1177ce
child 2575 b9697c489261
     1.1 --- a/src/keymanagement.c	Wed Mar 14 10:03:20 2018 +0100
     1.2 +++ b/src/keymanagement.c	Thu Mar 15 14:00:07 2018 +0100
     1.3 @@ -512,6 +512,7 @@
     1.4      if (identity->me || 
     1.5         (default_own_id && identity->user_id && (strcmp(default_own_id, identity->user_id) == 0))) 
     1.6      {
     1.7 +        free(default_own_id);
     1.8          return PEP_ILLEGAL_VALUE;
     1.9      }
    1.10  
    1.11 @@ -558,6 +559,7 @@
    1.12                                                          identity->user_id);
    1.13                                  if (status != PEP_STATUS_OK) {
    1.14                                      free_identity_list(id_list);
    1.15 +                                    free(default_own_id);
    1.16                                      return status;
    1.17                                  }
    1.18                                      
    1.19 @@ -681,7 +683,7 @@
    1.20          else {
    1.21              identity->user_id = calloc(1, strlen(identity->address) + 6);
    1.22              if (!identity->user_id)
    1.23 -                return PEP_OUT_OF_MEMORY;
    1.24 +                goto enomem;
    1.25  
    1.26              snprintf(identity->user_id, strlen(identity->address) + 6,
    1.27                       "TOFU_%s", identity->address);        
    1.28 @@ -757,14 +759,14 @@
    1.29              // This means TOFU_ user_id
    1.30              identity->user_id = calloc(1, strlen(identity->address) + 6);
    1.31              if (!identity->user_id)
    1.32 -                return PEP_OUT_OF_MEMORY;
    1.33 +                goto enomem;
    1.34  
    1.35              snprintf(identity->user_id, strlen(identity->address) + 6,
    1.36                       "TOFU_%s", identity->address);        
    1.37          
    1.38              identity->username = strdup(identity->address);
    1.39              if (!identity->address)
    1.40 -                return PEP_OUT_OF_MEMORY;            
    1.41 +                goto enomem;
    1.42              
    1.43              free(identity->fpr);
    1.44              identity->fpr = NULL;
    1.45 @@ -780,7 +782,6 @@
    1.46              status = set_identity(session, identity);
    1.47  
    1.48          }
    1.49 -            
    1.50      }
    1.51      
    1.52      // FIXME: This is legacy. I presume it's a notification for the caller...
    1.53 @@ -790,6 +791,13 @@
    1.54          if (session->examine_identity)
    1.55              session->examine_identity(identity, session->examine_management);
    1.56  
    1.57 +    goto pep_free;
    1.58 +
    1.59 +enomem:
    1.60 +    status = PEP_OUT_OF_MEMORY;
    1.61 +
    1.62 +pep_free:
    1.63 +    free(default_own_id);
    1.64      return status;
    1.65  }
    1.66