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


test/sslapitest.c:688:1: start of procedure ocsp_server_cb()
686.   
687.   #ifndef OPENSSL_NO_OCSP
688. > static int ocsp_server_cb(SSL *s, void *arg)
689.   {
690.       int *argi = (int *)arg;

test/sslapitest.c:690:5: 
688.   static int ocsp_server_cb(SSL *s, void *arg)
689.   {
690. >     int *argi = (int *)arg;
691.       unsigned char *copy = NULL;
692.       STACK_OF(OCSP_RESPID) *ids = NULL;

test/sslapitest.c:691:5: 
689.   {
690.       int *argi = (int *)arg;
691. >     unsigned char *copy = NULL;
692.       STACK_OF(OCSP_RESPID) *ids = NULL;
693.       OCSP_RESPID *id = NULL;

test/sslapitest.c:692:5: 
690.       int *argi = (int *)arg;
691.       unsigned char *copy = NULL;
692. >     STACK_OF(OCSP_RESPID) *ids = NULL;
693.       OCSP_RESPID *id = NULL;
694.   

test/sslapitest.c:693:5: 
691.       unsigned char *copy = NULL;
692.       STACK_OF(OCSP_RESPID) *ids = NULL;
693. >     OCSP_RESPID *id = NULL;
694.   
695.       if (*argi == 2) {

test/sslapitest.c:695:9: Taking false branch
693.       OCSP_RESPID *id = NULL;
694.   
695.       if (*argi == 2) {
               ^
696.           /* In this test we are expecting exactly 1 OCSP_RESPID */
697.           SSL_get_tlsext_status_ids(s, &ids);

test/sslapitest.c:704:16: Taking false branch
702.           if (id == NULL || !OCSP_RESPID_match(id, ocspcert))
703.               return SSL_TLSEXT_ERR_ALERT_FATAL;
704.       } else if (*argi != 1) {
                      ^
705.           return SSL_TLSEXT_ERR_ALERT_FATAL;
706.       }

test/sslapitest.c:708:10: 
706.       }
707.   
708. >     if (!TEST_ptr(copy = OPENSSL_memdup(orespder, sizeof(orespder))))
709.           return SSL_TLSEXT_ERR_ALERT_FATAL;
710.   

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:708:10: Taking false branch
706.       }
707.   
708.       if (!TEST_ptr(copy = OPENSSL_memdup(orespder, sizeof(orespder))))
                ^
709.           return SSL_TLSEXT_ERR_ALERT_FATAL;
710.   

test/sslapitest.c:711:5: Skipping SSL_ctrl(): empty list of specs
709.           return SSL_TLSEXT_ERR_ALERT_FATAL;
710.   
711.       SSL_set_tlsext_status_ocsp_resp(s, copy, sizeof(orespder));
           ^
712.       ocsp_server_called = 1;
713.       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}']