crypto/x509v3/v3_info.c:156: error: USE_AFTER_FREE
  call to `sk_ACCESS_DESCRIPTION_pop_free()` eventually accesses memory that was invalidated by call to `free()` on line 117 indirectly during the call to `sk_ACCESS_DESCRIPTION_reserve()`.
Showing all 22 steps of the trace


crypto/x509v3/v3_info.c:113:18: invalidation part of the trace starts here
111.       char *objtmp, *ptmp;
112.   
113.       if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
                        ^
114.           X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
115.           return NULL;

crypto/x509v3/v3_info.c:113:18: passed as argument to `sk_ACCESS_DESCRIPTION_new_null`
  111.       char *objtmp, *ptmp;
  112.   
  113.       if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
                          ^
  114.           X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
  115.           return NULL;

crypto/x509v3/v3_info.c:113:18: return from call to `sk_ACCESS_DESCRIPTION_new_null`
  111.       char *objtmp, *ptmp;
  112.   
  113.       if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
                          ^
  114.           X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
  115.           return NULL;

crypto/x509v3/v3_info.c:113:10: assigned
  111.       char *objtmp, *ptmp;
  112.   
  113.       if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
                  ^
  114.           X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
  115.           return NULL;

crypto/x509v3/v3_info.c:117:10: when calling `sk_ACCESS_DESCRIPTION_reserve` here
  115.           return NULL;
  116.       }
  117.       if (!sk_ACCESS_DESCRIPTION_reserve(ainfo, num))
                  ^
  118.           goto err;
  119.       for (i = 0; i < num; i++) {

include/openssl/x509v3.h:170:1: parameter `sk` of sk_ACCESS_DESCRIPTION_reserve
    168.   DEFINE_STACK_OF(GENERAL_NAMES)
    169.   
    170. > DEFINE_STACK_OF(ACCESS_DESCRIPTION)
    171.   
    172.   typedef struct DIST_POINT_NAME_st {

include/openssl/x509v3.h:170:1: when calling `OPENSSL_sk_reserve` here
    168.   DEFINE_STACK_OF(GENERAL_NAMES)
    169.   
    170. > DEFINE_STACK_OF(ACCESS_DESCRIPTION)
    171.   
    172.   typedef struct DIST_POINT_NAME_st {

crypto/stack/stack.c:206:1: parameter `st` of OPENSSL_sk_reserve
      204.   }
      205.   
      206. > int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n)
      207.   {
      208.       if (st == NULL)

crypto/stack/stack.c:213:12: when calling `sk_reserve` here
      211.       if (n < 0)
      212.           return 1;
      213.       return sk_reserve(st, n, 1);
                        ^
      214.   }
      215.   

crypto/stack/stack.c:160:1: parameter `st` of sk_reserve
        158.   
        159.   /* internal STACK storage allocation */
        160. > static int sk_reserve(OPENSSL_STACK *st, int n, int exact)
        161.   {
        162.       const void **tmpdata;

crypto/stack/stack.c:197:15: when calling `CRYPTO_realloc` here
        195.       }
        196.   
        197.       tmpdata = OPENSSL_realloc((void *)st->data, sizeof(void *) * num_alloc);
                             ^
        198.       if (tmpdata == NULL)
        199.           return 0;

crypto/mem.c:228:1: parameter `str` of CRYPTO_realloc
          226.   }
          227.   
          228. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
          229.   {
          230.       INCREMENT(realloc_count);

crypto/mem.c:239:9: when calling `CRYPTO_free` here
          237.   
          238.       if (num == 0) {
          239.           CRYPTO_free(str, file, line);
                         ^
          240.           return NULL;
          241.       }

crypto/mem.c:286:1: parameter `str` of CRYPTO_free
            284.   }
            285.   
            286. > void CRYPTO_free(void *str, const char *file, int line)
            287.   {
            288.       INCREMENT(free_count);

crypto/mem.c:303:5: was invalidated by call to `free()`
            301.       }
            302.   #else
            303.       free(str);
                       ^
            304.   #endif
            305.   }

crypto/x509v3/v3_info.c:113:18: use-after-lifetime part of the trace starts here
111.       char *objtmp, *ptmp;
112.   
113.       if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
                        ^
114.           X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
115.           return NULL;

crypto/x509v3/v3_info.c:113:18: passed as argument to `sk_ACCESS_DESCRIPTION_new_null`
  111.       char *objtmp, *ptmp;
  112.   
  113.       if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
                          ^
  114.           X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
  115.           return NULL;

crypto/x509v3/v3_info.c:113:18: return from call to `sk_ACCESS_DESCRIPTION_new_null`
  111.       char *objtmp, *ptmp;
  112.   
  113.       if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
                          ^
  114.           X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
  115.           return NULL;

crypto/x509v3/v3_info.c:113:10: assigned
  111.       char *objtmp, *ptmp;
  112.   
  113.       if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {
                  ^
  114.           X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
  115.           return NULL;

crypto/x509v3/v3_info.c:156:5: when calling `sk_ACCESS_DESCRIPTION_pop_free` here
  154.       return ainfo;
  155.    err:
  156.       sk_ACCESS_DESCRIPTION_pop_free(ainfo, ACCESS_DESCRIPTION_free);
             ^
  157.       return NULL;
  158.   }

crypto/mem.c:286:1: parameter `str` of CRYPTO_free
    284.   }
    285.   
    286. > void CRYPTO_free(void *str, const char *file, int line)
    287.   {
    288.       INCREMENT(free_count);

crypto/mem.c:303:5: invalid access occurs here
    301.       }
    302.   #else
    303.       free(str);
               ^
    304.   #endif
    305.   }

void CRYPTO_free(void *str, const char *file, int line)
{
    INCREMENT(free_count);
    if (free_impl != NULL && free_impl != &CRYPTO_free) {
        free_impl(str, file, line);
        return;
    }
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        CRYPTO_mem_debug_free(str, 0, file, line);
        free(str);
        CRYPTO_mem_debug_free(str, 1, file, line);
    } else {
        free(str);
    }
#else
    free(str);
#endif
}
['static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD\n                                                        *method,\n                                                        X509V3_CTX *ctx,\n                                                        STACK_OF(CONF_VALUE)\n                                                        *nval)\n{\n    AUTHORITY_INFO_ACCESS *ainfo = NULL;\n    CONF_VALUE *cnf, ctmp;\n    ACCESS_DESCRIPTION *acc;\n    int i, objlen;\n    const int num = sk_CONF_VALUE_num(nval);\n    char *objtmp, *ptmp;\n    if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) {\n        X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    if (!sk_ACCESS_DESCRIPTION_reserve(ainfo, num))\n        goto err;\n    for (i = 0; i < num; i++) {\n        cnf = sk_CONF_VALUE_value(nval, i);\n        if ((acc = ACCESS_DESCRIPTION_new()) == NULL) {\n            X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,\n                      ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        sk_ACCESS_DESCRIPTION_push(ainfo, acc);\n        ptmp = strchr(cnf->name, \';\');\n        if (!ptmp) {\n            X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,\n                      X509V3_R_INVALID_SYNTAX);\n            goto err;\n        }\n        objlen = ptmp - cnf->name;\n        ctmp.name = ptmp + 1;\n        ctmp.value = cnf->value;\n        if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0))\n            goto err;\n        if ((objtmp = OPENSSL_strndup(cnf->name, objlen)) == NULL) {\n            X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,\n                      ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        acc->method = OBJ_txt2obj(objtmp, 0);\n        if (!acc->method) {\n            X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,\n                      X509V3_R_BAD_OBJECT);\n            ERR_add_error_data(2, "value=", objtmp);\n            OPENSSL_free(objtmp);\n            goto err;\n        }\n        OPENSSL_free(objtmp);\n    }\n    return ainfo;\n err:\n    sk_ACCESS_DESCRIPTION_pop_free(ainfo, ACCESS_DESCRIPTION_free);\n    return NULL;\n}', 'int OPENSSL_sk_reserve(OPENSSL_STACK *st, int n)\n{\n    if (st == NULL)\n        return 0;\n    if (n < 0)\n        return 1;\n    return sk_reserve(st, n, 1);\n}', 'static int sk_reserve(OPENSSL_STACK *st, int n, int exact)\n{\n    const void **tmpdata;\n    int num_alloc;\n    if (n > max_nodes - st->num)\n        return 0;\n    num_alloc = st->num + n;\n    if (num_alloc < min_nodes)\n        num_alloc = min_nodes;\n    if (st->data == NULL) {\n        st->data = OPENSSL_zalloc(sizeof(void *) * num_alloc);\n        if (st->data == NULL)\n            return 0;\n        st->num_alloc = num_alloc;\n        return 1;\n    }\n    if (!exact) {\n        if (num_alloc <= st->num_alloc)\n            return 1;\n        num_alloc = compute_growth(num_alloc, st->num_alloc);\n        if (num_alloc == 0)\n            return 0;\n    } else if (num_alloc == st->num_alloc) {\n        return 1;\n    }\n    tmpdata = OPENSSL_realloc((void *)st->data, sizeof(void *) * num_alloc);\n    if (tmpdata == NULL)\n        return 0;\n    st->data = tmpdata;\n    st->num_alloc = num_alloc;\n    return 1;\n}', 'void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)\n{\n    INCREMENT(realloc_count);\n    if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)\n        return realloc_impl(str, num, file, line);\n    FAILTEST();\n    if (str == NULL)\n        return CRYPTO_malloc(num, file, line);\n    if (num == 0) {\n        CRYPTO_free(str, file, line);\n        return NULL;\n    }\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        void *ret;\n        CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);\n        ret = realloc(str, num);\n        CRYPTO_mem_debug_realloc(str, ret, num, 1, file, line);\n        return ret;\n    }\n#else\n    (void)(file); (void)(line);\n#endif\n    return realloc(str, num);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    INCREMENT(free_count);\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']