crypto/property/property.c:232: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `alg_cleanup`.
Showing all 13 steps of the trace


crypto/property/property.c:215:34: Call
213.           if ((alg = OPENSSL_zalloc(sizeof(*alg))) == NULL
214.                   || (alg->impls = sk_IMPLEMENTATION_new_null()) == NULL
215.                   || (alg->cache = lh_QUERY_new(&query_hash, &query_cmp)) == NULL)
                                        ^
216.               goto err;
217.           alg->nid = nid;

crypto/property/property.c:41:1: Call
  39.   } QUERY;
  40.   
  41. > DEFINE_LHASH_OF(QUERY);
  42.   
  43.   typedef struct {

crypto/lhash/lhash.c:63:5: Assignment
    61.       ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c);
    62.       ret->hash = ((h == NULL) ? (OPENSSL_LH_HASHFUNC)OPENSSL_LH_strhash : h);
    63.       ret->num_nodes = MIN_NODES / 2;
              ^
    64.       ret->num_alloc_nodes = MIN_NODES;
    65.       ret->pmax = MIN_NODES / 2;

crypto/property/property.c:232:5: Call
230.   err:
231.       ossl_property_unlock(store);
232.       alg_cleanup(0, alg);
           ^
233.       impl_free(impl);
234.       return 0;

crypto/property/property.c:116:1: Parameter `a->cache->num_nodes`
  114.   }
  115.   
  116. > static void alg_cleanup(ossl_uintmax_t idx, ALGORITHM *a)
  117.   {
  118.       if (a != NULL) {

crypto/property/property.c:120:9: Call
  118.       if (a != NULL) {
  119.           sk_IMPLEMENTATION_pop_free(a->impls, &impl_free);
  120.           lh_QUERY_doall(a->cache, &impl_cache_free);
                 ^
  121.           lh_QUERY_free(a->cache);
  122.           OPENSSL_free(a);

crypto/property/property.c:41:1: Parameter `lh->num_nodes`
    39.   } QUERY;
    40.   
    41. > DEFINE_LHASH_OF(QUERY);
    42.   
    43.   typedef struct {

crypto/property/property.c:41:1: Call
    39.   } QUERY;
    40.   
    41. > DEFINE_LHASH_OF(QUERY);
    42.   
    43.   typedef struct {

crypto/lhash/lhash.c:213:1: Parameter `lh->num_nodes`
      211.   }
      212.   
      213. > void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func)
      214.   {
      215.       doall_util_fn(lh, 0, func, (OPENSSL_LH_DOALL_FUNCARG)0, NULL);

crypto/lhash/lhash.c:215:5: Call
      213.   void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func)
      214.   {
      215.       doall_util_fn(lh, 0, func, (OPENSSL_LH_DOALL_FUNCARG)0, NULL);
                 ^
      216.   }
      217.   

crypto/lhash/lhash.c:186:1: <LHS trace>
184.   }
185.   
186. > static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
187.                             OPENSSL_LH_DOALL_FUNC func,
188.                             OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)

crypto/lhash/lhash.c:186:1: Parameter `lh->num_nodes`
        184.   }
        185.   
        186. > static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
        187.                             OPENSSL_LH_DOALL_FUNC func,
        188.                             OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)

crypto/lhash/lhash.c:200:10: Binary operation: ([0, +oo] - 1):unsigned32 by call to `alg_cleanup` 
        198.        * memory leaks otherwise
        199.        */
        200.       for (i = lh->num_nodes - 1; i >= 0; i--) {
                        ^
        201.           a = lh->b[i];
        202.           while (a != NULL) {

static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
                          OPENSSL_LH_DOALL_FUNC func,
                          OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)
{
    int i;
    OPENSSL_LH_NODE *a, *n;
    if (lh == NULL)
        return;
    for (i = lh->num_nodes - 1; i >= 0; i--) {
        a = lh->b[i];
        while (a != NULL) {
            n = a->next;
            if (use_arg)
                func_arg(a->data, arg);
            else
                func(a->data);
            a = n;
        }
    }
}
['int ossl_method_store_add(OSSL_METHOD_STORE *store,\n                          int nid, const char *properties,\n                          void *method, void (*method_destruct)(void *))\n{\n    ALGORITHM *alg = NULL;\n    IMPLEMENTATION *impl;\n    int ret = 0;\n    if (nid <= 0 || method == NULL || store == NULL)\n        return 0;\n    if (properties == NULL)\n        properties = "";\n    impl = OPENSSL_malloc(sizeof(*impl));\n    if (impl == NULL)\n        return 0;\n    impl->method = method;\n    impl->method_destruct = method_destruct;\n    ossl_property_write_lock(store);\n    ossl_method_cache_flush(store, nid);\n    if ((impl->properties = ossl_prop_defn_get(store->ctx, properties)) == NULL) {\n        impl->properties = ossl_parse_property(store->ctx, properties);\n        if (impl->properties == NULL)\n            goto err;\n        ossl_prop_defn_set(store->ctx, properties, impl->properties);\n    }\n    alg = ossl_method_store_retrieve(store, nid);\n    if (alg == NULL) {\n        if ((alg = OPENSSL_zalloc(sizeof(*alg))) == NULL\n                || (alg->impls = sk_IMPLEMENTATION_new_null()) == NULL\n                || (alg->cache = lh_QUERY_new(&query_hash, &query_cmp)) == NULL)\n            goto err;\n        alg->nid = nid;\n        if (!ossl_method_store_insert(store, alg))\n            goto err;\n    }\n    if (sk_IMPLEMENTATION_push(alg->impls, impl))\n        ret = 1;\n    ossl_property_unlock(store);\n    if (ret == 0)\n        impl_free(impl);\n    return ret;\nerr:\n    ossl_property_unlock(store);\n    alg_cleanup(0, alg);\n    impl_free(impl);\n    return 0;\n}', 'DEFINE_LHASH_OF(QUERY)', 'OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c)\n{\n    OPENSSL_LHASH *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        return NULL;\n    }\n    if ((ret->b = OPENSSL_zalloc(sizeof(*ret->b) * MIN_NODES)) == NULL)\n        goto err;\n    ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c);\n    ret->hash = ((h == NULL) ? (OPENSSL_LH_HASHFUNC)OPENSSL_LH_strhash : h);\n    ret->num_nodes = MIN_NODES / 2;\n    ret->num_alloc_nodes = MIN_NODES;\n    ret->pmax = MIN_NODES / 2;\n    ret->up_load = UP_LOAD;\n    ret->down_load = DOWN_LOAD;\n    return ret;\nerr:\n    OPENSSL_free(ret->b);\n    OPENSSL_free(ret);\n    return NULL;\n}', 'static void alg_cleanup(ossl_uintmax_t idx, ALGORITHM *a)\n{\n    if (a != NULL) {\n        sk_IMPLEMENTATION_pop_free(a->impls, &impl_free);\n        lh_QUERY_doall(a->cache, &impl_cache_free);\n        lh_QUERY_free(a->cache);\n        OPENSSL_free(a);\n    }\n}', 'void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func)\n{\n    doall_util_fn(lh, 0, func, (OPENSSL_LH_DOALL_FUNCARG)0, NULL);\n}', 'static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,\n                          OPENSSL_LH_DOALL_FUNC func,\n                          OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)\n{\n    int i;\n    OPENSSL_LH_NODE *a, *n;\n    if (lh == NULL)\n        return;\n    for (i = lh->num_nodes - 1; i >= 0; i--) {\n        a = lh->b[i];\n        while (a != NULL) {\n            n = a->next;\n            if (use_arg)\n                func_arg(a->data, arg);\n            else\n                func(a->data);\n            a = n;\n        }\n    }\n}']