some safeguards sync
authorVolker Birk <vb@pep.foundation>
Sun, 21 Oct 2018 12:31:32 +0200
branchsync
changeset 3083da1eb049cca1
parent 3082 e865e13adf75
child 3084 2addd22aad87
some safeguards
src/pgp_gpg.c
src/resource_id.c
     1.1 --- a/src/pgp_gpg.c	Sun Oct 21 12:27:22 2018 +0200
     1.2 +++ b/src/pgp_gpg.c	Sun Oct 21 12:31:32 2018 +0200
     1.3 @@ -116,6 +116,9 @@
     1.4          at = address + addr_len;
     1.5          
     1.6      char* retval = calloc(1, addr_len + 1);
     1.7 +    assert(retval);
     1.8 +    if (!retval)
     1.9 +        return NULL;
    1.10  
    1.11      const char* addr_curr = address;
    1.12      char* retval_curr = retval;
     2.1 --- a/src/resource_id.c	Sun Oct 21 12:27:22 2018 +0200
     2.2 +++ b/src/resource_id.c	Sun Oct 21 12:31:32 2018 +0200
     2.3 @@ -5,9 +5,22 @@
     2.4  #include "resource_id.h"
     2.5  
     2.6  pEp_rid_list_t* new_rid_node(pEp_resource_id_type type, const char* resource) {
     2.7 +    assert(resource);
     2.8 +    if (!resource)
     2.9 +        return NULL;
    2.10 +
    2.11      pEp_rid_list_t* retval = (pEp_rid_list_t*)calloc(1, sizeof(pEp_rid_list_t));
    2.12 +    assert(retval);
    2.13 +    if (!retval)
    2.14 +        return NULL;
    2.15 +
    2.16      retval->rid_type = type;
    2.17      retval->rid = strdup(resource);
    2.18 +    assert(retval->rid);
    2.19 +    if (!retval->rid) {
    2.20 +        free(retval);
    2.21 +        return NULL;
    2.22 +    }
    2.23      return retval;
    2.24  }
    2.25