test/sslapitest.c:898: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_memdup()` at line 895, column 10 is not reachable after line 898, column 5.
Showing all 31 steps of the trace


test/sslapitest.c:875:1: start of procedure ocsp_server_cb()
873.   
874.   #ifndef OPENSSL_NO_OCSP
875. > static int ocsp_server_cb(SSL *s, void *arg)
876.   {
877.       int *argi = (int *)arg;

test/sslapitest.c:877:5: 
875.   static int ocsp_server_cb(SSL *s, void *arg)
876.   {
877. >     int *argi = (int *)arg;
878.       unsigned char *copy = NULL;
879.       STACK_OF(OCSP_RESPID) *ids = NULL;

test/sslapitest.c:878:5: 
876.   {
877.       int *argi = (int *)arg;
878. >     unsigned char *copy = NULL;
879.       STACK_OF(OCSP_RESPID) *ids = NULL;
880.       OCSP_RESPID *id = NULL;

test/sslapitest.c:879:5: 
877.       int *argi = (int *)arg;
878.       unsigned char *copy = NULL;
879. >     STACK_OF(OCSP_RESPID) *ids = NULL;
880.       OCSP_RESPID *id = NULL;
881.   

test/sslapitest.c:880:5: 
878.       unsigned char *copy = NULL;
879.       STACK_OF(OCSP_RESPID) *ids = NULL;
880. >     OCSP_RESPID *id = NULL;
881.   
882.       if (*argi == 2) {

test/sslapitest.c:882:9: Taking false branch
880.       OCSP_RESPID *id = NULL;
881.   
882.       if (*argi == 2) {
               ^
883.           /* In this test we are expecting exactly 1 OCSP_RESPID */
884.           SSL_get_tlsext_status_ids(s, &ids);

test/sslapitest.c:891:16: Taking false branch
889.           if (id == NULL || !OCSP_RESPID_match(id, ocspcert))
890.               return SSL_TLSEXT_ERR_ALERT_FATAL;
891.       } else if (*argi != 1) {
                      ^
892.           return SSL_TLSEXT_ERR_ALERT_FATAL;
893.       }

test/sslapitest.c:895:10: 
893.       }
894.   
895. >     if (!TEST_ptr(copy = OPENSSL_memdup(orespder, sizeof(orespder))))
896.           return SSL_TLSEXT_ERR_ALERT_FATAL;
897.   

crypto/o_str.c:57:1: start of procedure CRYPTO_memdup()
  55.   }
  56.   
  57. > void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line)
  58.   {
  59.       void *ret;

crypto/o_str.c:61:9: Taking false branch
  59.       void *ret;
  60.   
  61.       if (data == NULL || siz >= INT_MAX)
                ^
  62.           return NULL;
  63.   

crypto/o_str.c:61:25: Taking false branch
  59.       void *ret;
  60.   
  61.       if (data == NULL || siz >= INT_MAX)
                                ^
  62.           return NULL;
  63.   

crypto/o_str.c:64:5: 
  62.           return NULL;
  63.   
  64. >     ret = CRYPTO_malloc(siz, file, line);
  65.       if (ret == NULL) {
  66.           CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE);

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
    190.   #endif
    191.   
    192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194.       void *ret = NULL;

crypto/mem.c:194:5: 
    192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194. >     void *ret = NULL;
    195.   
    196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:200:9: Taking false branch
    198.           return malloc_impl(num, file, line);
    199.   
    200.       if (num == 0)
                   ^
    201.           return NULL;
    202.   

crypto/mem.c:204:9: Taking false branch
    202.   
    203.       FAILTEST();
    204.       if (allow_customize) {
                   ^
    205.           /*
    206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:221:5: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:221:19: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:222:5: 
    220.   #else
    221.       (void)(file); (void)(line);
    222. >     ret = malloc(num);
    223.   #endif
    224.   

crypto/mem.c:225:5: 
    223.   #endif
    224.   
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
    224.   
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/o_str.c:65:9: Taking false branch
  63.   
  64.       ret = CRYPTO_malloc(siz, file, line);
  65.       if (ret == NULL) {
                ^
  66.           CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE);
  67.           return NULL;

crypto/o_str.c:69:5: 
  67.           return NULL;
  68.       }
  69. >     return memcpy(ret, data, siz);
  70.   }
  71.   

crypto/o_str.c:70:1: return from a call to CRYPTO_memdup
  68.       }
  69.       return memcpy(ret, data, siz);
  70. > }
  71.   
  72.   size_t OPENSSL_strnlen(const char *str, size_t maxlen)

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/sslapitest.c:895:10: Taking false branch
893.       }
894.   
895.       if (!TEST_ptr(copy = OPENSSL_memdup(orespder, sizeof(orespder))))
                ^
896.           return SSL_TLSEXT_ERR_ALERT_FATAL;
897.   

test/sslapitest.c:898:5: Skipping SSL_ctrl(): empty list of specs
896.           return SSL_TLSEXT_ERR_ALERT_FATAL;
897.   
898.       SSL_set_tlsext_status_ocsp_resp(s, copy, sizeof(orespder));
           ^
899.       ocsp_server_called = 1;
900.       return SSL_TLSEXT_ERR_OK;

static int ocsp_server_cb(SSL *s, void *arg)
{
    int *argi = (int *)arg;
    unsigned char *copy = NULL;
    STACK_OF(OCSP_RESPID) *ids = NULL;
    OCSP_RESPID *id = NULL;
    if (*argi == 2) {
        SSL_get_tlsext_status_ids(s, &ids);
        if (ids == NULL || sk_OCSP_RESPID_num(ids) != 1)
            return SSL_TLSEXT_ERR_ALERT_FATAL;
        id = sk_OCSP_RESPID_value(ids, 0);
        if (id == NULL || !OCSP_RESPID_match(id, ocspcert))
            return SSL_TLSEXT_ERR_ALERT_FATAL;
    } else if (*argi != 1) {
        return SSL_TLSEXT_ERR_ALERT_FATAL;
    }
    if (!TEST_ptr(copy = OPENSSL_memdup(orespder, sizeof(orespder))))
        return SSL_TLSEXT_ERR_ALERT_FATAL;
    SSL_set_tlsext_status_ocsp_resp(s, copy, sizeof(orespder));
    ocsp_server_called = 1;
    return SSL_TLSEXT_ERR_OK;
}
['static int ocsp_server_cb(SSL *s, void *arg)\n{\n    int *argi = (int *)arg;\n    unsigned char *copy = NULL;\n    STACK_OF(OCSP_RESPID) *ids = NULL;\n    OCSP_RESPID *id = NULL;\n    if (*argi == 2) {\n        SSL_get_tlsext_status_ids(s, &ids);\n        if (ids == NULL || sk_OCSP_RESPID_num(ids) != 1)\n            return SSL_TLSEXT_ERR_ALERT_FATAL;\n        id = sk_OCSP_RESPID_value(ids, 0);\n        if (id == NULL || !OCSP_RESPID_match(id, ocspcert))\n            return SSL_TLSEXT_ERR_ALERT_FATAL;\n    } else if (*argi != 1) {\n        return SSL_TLSEXT_ERR_ALERT_FATAL;\n    }\n    if (!TEST_ptr(copy = OPENSSL_memdup(orespder, sizeof(orespder))))\n        return SSL_TLSEXT_ERR_ALERT_FATAL;\n    SSL_set_tlsext_status_ocsp_resp(s, copy, sizeof(orespder));\n    ocsp_server_called = 1;\n    return SSL_TLSEXT_ERR_OK;\n}', 'void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line)\n{\n    void *ret;\n    if (data == NULL || siz >= INT_MAX)\n        return NULL;\n    ret = CRYPTO_malloc(siz, file, line);\n    if (ret == NULL) {\n        CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    return memcpy(ret, data, siz);\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int test_ptr(const char *file, int line, const char *s, const void *p)\n{\n    if (p != NULL)\n        return 1;\n    test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);\n    return 0;\n}']