ENGINE-DIRKSAIDSO: strdup(NULL) is bad, mmmkay?
authorKrista Bennett <krista@pep-project.org>
Mon, 19 Feb 2018 15:34:10 +0100
changeset 252270df192d5904
parent 2521 9ed30868146c
child 2523 a66d3a57ddf3
child 2524 aa720ce48018
ENGINE-DIRKSAIDSO: strdup(NULL) is bad, mmmkay?
src/keymanagement.c
     1.1 --- a/src/keymanagement.c	Mon Feb 19 13:59:49 2018 +0100
     1.2 +++ b/src/keymanagement.c	Mon Feb 19 15:34:10 2018 +0100
     1.3 @@ -1321,7 +1321,7 @@
     1.4          goto pep_free;
     1.5      }
     1.6      
     1.7 -    // Save the input fpr
     1.8 +    // Save the input fpr, which we already tested as non-NULL
     1.9      cached_fpr = strdup(ident->fpr);
    1.10  
    1.11      // First, set up a temp trusted identity for the input fpr without a comm type;
    1.12 @@ -1335,7 +1335,7 @@
    1.13                                         
    1.14          // Get the default identity without setting the fpr
    1.15          status = update_identity(session, ident_copy);
    1.16 -        ident_default_fpr = strdup(ident_copy->fpr);
    1.17 +        ident_default_fpr = (EMPTYSTR(ident_copy->fpr) ? NULL : strdup(ident_copy->fpr));
    1.18  
    1.19          if (status == PEP_STATUS_OK) {
    1.20              bool trusted_default = false;