ssl/d1_srtp.c:108: error: USE_AFTER_FREE
  call to `sk_SRTP_PROTECTION_PROFILE_free()` eventually accesses memory that was invalidated by call to `free()` on line 87 indirectly during the call to `sk_SRTP_PROTECTION_PROFILE_push()`.
Showing all 24 steps of the trace


ssl/d1_srtp.c:70:21: invalidation part of the trace starts here
68.       SRTP_PROTECTION_PROFILE *p;
69.   
70.       if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
                          ^
71.           SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
72.                  SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

ssl/d1_srtp.c:70:21: passed as argument to `sk_SRTP_PROTECTION_PROFILE_new_null`
  68.       SRTP_PROTECTION_PROFILE *p;
  69.   
  70.       if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
                            ^
  71.           SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
  72.                  SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

ssl/d1_srtp.c:70:21: return from call to `sk_SRTP_PROTECTION_PROFILE_new_null`
  68.       SRTP_PROTECTION_PROFILE *p;
  69.   
  70.       if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
                            ^
  71.           SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
  72.                  SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

ssl/d1_srtp.c:70:10: assigned
  68.       SRTP_PROTECTION_PROFILE *p;
  69.   
  70.       if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
                 ^
  71.           SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
  72.                  SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

ssl/d1_srtp.c:87:18: when calling `sk_SRTP_PROTECTION_PROFILE_push` here
  85.               }
  86.   
  87.               if (!sk_SRTP_PROTECTION_PROFILE_push(profiles, p)) {
                         ^
  88.                   SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
  89.                          SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

include/openssl/ssl.h:218:1: parameter `sk` of sk_SRTP_PROTECTION_PROFILE_push
    216.   } SRTP_PROTECTION_PROFILE;
    217.   
    218. > DEFINE_STACK_OF(SRTP_PROTECTION_PROFILE)
    219.   
    220.   typedef int (*tls_session_ticket_ext_cb_fn) (SSL *s,

include/openssl/ssl.h:218:1: when calling `OPENSSL_sk_push` here
    216.   } SRTP_PROTECTION_PROFILE;
    217.   
    218. > DEFINE_STACK_OF(SRTP_PROTECTION_PROFILE)
    219.   
    220.   typedef int (*tls_session_ticket_ext_cb_fn) (SSL *s,

crypto/stack/stack.c:305:1: parameter `st` of OPENSSL_sk_push
      303.   }
      304.   
      305. > int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)
      306.   {
      307.       if (st == NULL)

crypto/stack/stack.c:309:12: when calling `OPENSSL_sk_insert` here
      307.       if (st == NULL)
      308.           return -1;
      309.       return OPENSSL_sk_insert(st, data, st->num);
                        ^
      310.   }
      311.   

crypto/stack/stack.c:216:1: parameter `st` of OPENSSL_sk_insert
        214.   }
        215.   
        216. > int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
        217.   {
        218.       if (st == NULL || st->num == max_nodes)

crypto/stack/stack.c:221:10: when calling `sk_reserve` here
        219.           return 0;
        220.   
        221.       if (!sk_reserve(st, 1, 0))
                        ^
        222.           return 0;
        223.   

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.   }

ssl/d1_srtp.c:70:21: use-after-lifetime part of the trace starts here
68.       SRTP_PROTECTION_PROFILE *p;
69.   
70.       if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
                          ^
71.           SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
72.                  SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

ssl/d1_srtp.c:70:21: passed as argument to `sk_SRTP_PROTECTION_PROFILE_new_null`
  68.       SRTP_PROTECTION_PROFILE *p;
  69.   
  70.       if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
                            ^
  71.           SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
  72.                  SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

ssl/d1_srtp.c:70:21: return from call to `sk_SRTP_PROTECTION_PROFILE_new_null`
  68.       SRTP_PROTECTION_PROFILE *p;
  69.   
  70.       if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
                            ^
  71.           SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
  72.                  SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

ssl/d1_srtp.c:70:10: assigned
  68.       SRTP_PROTECTION_PROFILE *p;
  69.   
  70.       if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {
                 ^
  71.           SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,
  72.                  SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);

ssl/d1_srtp.c:108:5: when calling `sk_SRTP_PROTECTION_PROFILE_free` here
  106.       return 0;
  107.    err:
  108.       sk_SRTP_PROTECTION_PROFILE_free(profiles);
             ^
  109.       return 1;
  110.   }

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 int ssl_ctx_make_profiles(const char *profiles_string,\n                                 STACK_OF(SRTP_PROTECTION_PROFILE) **out)\n{\n    STACK_OF(SRTP_PROTECTION_PROFILE) *profiles;\n    char *col;\n    char *ptr = (char *)profiles_string;\n    SRTP_PROTECTION_PROFILE *p;\n    if ((profiles = sk_SRTP_PROTECTION_PROFILE_new_null()) == NULL) {\n        SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,\n               SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);\n        return 1;\n    }\n    do {\n        col = strchr(ptr, ':');\n        if (!find_profile_by_name(ptr, &p, col ? (size_t)(col - ptr)\n                                               : strlen(ptr))) {\n            if (sk_SRTP_PROTECTION_PROFILE_find(profiles, p) >= 0) {\n                SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,\n                       SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST);\n                goto err;\n            }\n            if (!sk_SRTP_PROTECTION_PROFILE_push(profiles, p)) {\n                SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,\n                       SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES);\n                goto err;\n            }\n        } else {\n            SSLerr(SSL_F_SSL_CTX_MAKE_PROFILES,\n                   SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE);\n            goto err;\n        }\n        if (col)\n            ptr = col + 1;\n    } while (col);\n    sk_SRTP_PROTECTION_PROFILE_free(*out);\n    *out = profiles;\n    return 0;\n err:\n    sk_SRTP_PROTECTION_PROFILE_free(profiles);\n    return 1;\n}", 'DEFINE_STACK_OF(SRTP_PROTECTION_PROFILE)', 'int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)\n{\n    if (st == NULL)\n        return -1;\n    return OPENSSL_sk_insert(st, data, st->num);\n}', 'int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)\n{\n    if (st == NULL || st->num == max_nodes)\n        return 0;\n    if (!sk_reserve(st, 1, 0))\n        return 0;\n    if ((loc >= st->num) || (loc < 0)) {\n        st->data[st->num] = data;\n    } else {\n        memmove(&st->data[loc + 1], &st->data[loc],\n                sizeof(st->data[0]) * (st->num - loc));\n        st->data[loc] = data;\n    }\n    st->num++;\n    st->sorted = 0;\n    return st->num;\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}']