... sync
authorVolker Birk <vb@pep-project.org>
Sat, 18 May 2019 21:01:32 +0200
branchsync
changeset 372111c6d627b261
parent 3720 9ed76a79d784
child 3722 0f31947b826d
...
src/keymanagement.c
     1.1 --- a/src/keymanagement.c	Fri May 17 17:59:06 2019 +0200
     1.2 +++ b/src/keymanagement.c	Sat May 18 21:01:32 2019 +0200
     1.3 @@ -1060,6 +1060,9 @@
     1.4          if (read_only) {
     1.5              free(identity->user_id);
     1.6              identity->user_id = strdup(default_own_id);
     1.7 +            assert(identity->user_id);
     1.8 +            if (!identity->user_id)
     1.9 +                return PEP_OUT_OF_MEMORY;
    1.10          }
    1.11          else {
    1.12              status = set_userid_alias(session, default_own_id, identity->user_id);
    1.13 @@ -1069,6 +1072,7 @@
    1.14                  
    1.15              free(identity->user_id);
    1.16              identity->user_id = strdup(default_own_id);
    1.17 +            assert(identity->user_id);
    1.18              if (identity->user_id == NULL) {
    1.19                  status = PEP_OUT_OF_MEMORY;
    1.20                  goto pEp_free;
    1.21 @@ -1108,11 +1112,14 @@
    1.22      if (EMPTYSTR(identity->username) || read_only) {
    1.23          bool stored_uname = (stored_identity && !EMPTYSTR(stored_identity->username));
    1.24          char* uname = (stored_uname ? stored_identity->username : identity->address);
    1.25 -        free(identity->username);
    1.26 -        identity->username = strdup(uname);
    1.27 -        if (identity->username == NULL) {
    1.28 -            status = PEP_OUT_OF_MEMORY;
    1.29 -            goto pEp_free;
    1.30 +        if (uname) {
    1.31 +            free(identity->username);
    1.32 +            identity->username = strdup(uname);
    1.33 +            assert(identity->username);
    1.34 +            if (identity->username == NULL) {
    1.35 +                status = PEP_OUT_OF_MEMORY;
    1.36 +                goto pEp_free;
    1.37 +            }
    1.38          }
    1.39      }
    1.40