test/evp_test.c:956: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_strdup()` at line 957, column 39 is not reachable after line 956, column 16.
Showing all 38 steps of the trace


test/evp_test.c:936:1: start of procedure mac_test_parse()
934.   }
935.   
936. > static int mac_test_parse(EVP_TEST *t,
937.                             const char *keyword, const char *value)
938.   {

test/evp_test.c:939:5: 
937.                             const char *keyword, const char *value)
938.   {
939. >     MAC_DATA *mdata = t->data;
940.   
941.       if (strcmp(keyword, "Key") == 0)

test/evp_test.c:941:9: Taking false branch
939.       MAC_DATA *mdata = t->data;
940.   
941.       if (strcmp(keyword, "Key") == 0)
               ^
942.           return parse_bin(value, &mdata->key, &mdata->key_len);
943.       if (strcmp(keyword, "IV") == 0)

test/evp_test.c:943:9: Taking false branch
941.       if (strcmp(keyword, "Key") == 0)
942.           return parse_bin(value, &mdata->key, &mdata->key_len);
943.       if (strcmp(keyword, "IV") == 0)
               ^
944.           return parse_bin(value, &mdata->iv, &mdata->iv_len);
945.       if (strcmp(keyword, "Algorithm") == 0) {

test/evp_test.c:945:9: Taking false branch
943.       if (strcmp(keyword, "IV") == 0)
944.           return parse_bin(value, &mdata->iv, &mdata->iv_len);
945.       if (strcmp(keyword, "Algorithm") == 0) {
               ^
946.           mdata->alg = OPENSSL_strdup(value);
947.           if (!mdata->alg)

test/evp_test.c:951:9: Taking false branch
949.           return 1;
950.       }
951.       if (strcmp(keyword, "Input") == 0)
               ^
952.           return parse_bin(value, &mdata->input, &mdata->input_len);
953.       if (strcmp(keyword, "Output") == 0)

test/evp_test.c:953:9: Taking false branch
951.       if (strcmp(keyword, "Input") == 0)
952.           return parse_bin(value, &mdata->input, &mdata->input_len);
953.       if (strcmp(keyword, "Output") == 0)
               ^
954.           return parse_bin(value, &mdata->output, &mdata->output_len);
955.       if (strcmp(keyword, "Ctrl") == 0)

test/evp_test.c:955:9: Taking true branch
953.       if (strcmp(keyword, "Output") == 0)
954.           return parse_bin(value, &mdata->output, &mdata->output_len);
955.       if (strcmp(keyword, "Ctrl") == 0)
               ^
956.           return sk_OPENSSL_STRING_push(mdata->controls,
957.                                         OPENSSL_strdup(value)) != 0;

test/evp_test.c:956:16: 
954.           return parse_bin(value, &mdata->output, &mdata->output_len);
955.       if (strcmp(keyword, "Ctrl") == 0)
956. >         return sk_OPENSSL_STRING_push(mdata->controls,
957.                                         OPENSSL_strdup(value)) != 0;
958.       return 0;

crypto/o_str.c:27:1: start of procedure CRYPTO_strdup()
  25.   }
  26.   
  27. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  28.   {
  29.       char *ret;

crypto/o_str.c:31:9: Taking false branch
  29.       char *ret;
  30.   
  31.       if (str == NULL)
                ^
  32.           return NULL;
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);

crypto/o_str.c:33:5: 
  31.       if (str == NULL)
  32.           return NULL;
  33. >     ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
  35.           strcpy(ret, str);

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:34:9: Taking true branch
  32.           return NULL;
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
                ^
  35.           strcpy(ret, str);
  36.       return ret;

crypto/o_str.c:35:9: 
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
  35. >         strcpy(ret, str);
  36.       return ret;
  37.   }

crypto/o_str.c:36:5: 
  34.       if (ret != NULL)
  35.           strcpy(ret, str);
  36. >     return ret;
  37.   }
  38.   

crypto/o_str.c:37:1: return from a call to CRYPTO_strdup
  35.           strcpy(ret, str);
  36.       return ret;
  37. > }
  38.   
  39.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

include/openssl/safestack.h:159:1: start of procedure sk_OPENSSL_STRING_push()
  157.    * dealt with in the autogenerated macros below.
  158.    */
  159. > DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
  160.   DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
  161.   

crypto/stack/stack.c:326:1: start of procedure OPENSSL_sk_push()
    324.   }
    325.   
    326. > int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)
    327.   {
    328.       if (st == NULL)

crypto/stack/stack.c:328:9: Taking false branch
    326.   int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)
    327.   {
    328.       if (st == NULL)
                   ^
    329.           return -1;
    330.       return OPENSSL_sk_insert(st, data, st->num);

crypto/stack/stack.c:330:5: 
    328.       if (st == NULL)
    329.           return -1;
    330. >     return OPENSSL_sk_insert(st, data, st->num);
    331.   }
    332.   

crypto/stack/stack.c:237:1: start of procedure OPENSSL_sk_insert()
      235.   }
      236.   
      237. > int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
      238.   {
      239.       if (st == NULL || st->num == max_nodes)

crypto/stack/stack.c:239:9: Taking false branch
      237.   int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
      238.   {
      239.       if (st == NULL || st->num == max_nodes)
                     ^
      240.           return 0;
      241.   

crypto/stack/stack.c:239:23: Taking false branch
      237.   int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
      238.   {
      239.       if (st == NULL || st->num == max_nodes)
                                   ^
      240.           return 0;
      241.   

crypto/stack/stack.c:242:10: Taking true branch
      240.           return 0;
      241.   
      242.       if (!sk_reserve(st, 1, 0))
                      ^
      243.           return 0;
      244.   

crypto/stack/stack.c:243:9: 
      241.   
      242.       if (!sk_reserve(st, 1, 0))
      243. >         return 0;
      244.   
      245.       if ((loc >= st->num) || (loc < 0)) {

crypto/stack/stack.c:255:1: return from a call to OPENSSL_sk_insert
      253.       st->sorted = 0;
      254.       return st->num;
      255. > }
      256.   
      257.   static ossl_inline void *internal_delete(OPENSSL_STACK *st, int loc)

crypto/stack/stack.c:331:1: return from a call to OPENSSL_sk_push
    329.           return -1;
    330.       return OPENSSL_sk_insert(st, data, st->num);
    331. > }
    332.   
    333.   int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data)

include/openssl/safestack.h:159:1: return from a call to sk_OPENSSL_STRING_push
  157.    * dealt with in the autogenerated macros below.
  158.    */
  159. > DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
  160.   DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
  161.   

static int mac_test_parse(EVP_TEST *t,
                          const char *keyword, const char *value)
{
    MAC_DATA *mdata = t->data;
    if (strcmp(keyword, "Key") == 0)
        return parse_bin(value, &mdata->key, &mdata->key_len);
    if (strcmp(keyword, "IV") == 0)
        return parse_bin(value, &mdata->iv, &mdata->iv_len);
    if (strcmp(keyword, "Algorithm") == 0) {
        mdata->alg = OPENSSL_strdup(value);
        if (!mdata->alg)
            return 0;
        return 1;
    }
    if (strcmp(keyword, "Input") == 0)
        return parse_bin(value, &mdata->input, &mdata->input_len);
    if (strcmp(keyword, "Output") == 0)
        return parse_bin(value, &mdata->output, &mdata->output_len);
    if (strcmp(keyword, "Ctrl") == 0)
        return sk_OPENSSL_STRING_push(mdata->controls,
                                      OPENSSL_strdup(value)) != 0;
    return 0;
}
['static int mac_test_parse(EVP_TEST *t,\n                          const char *keyword, const char *value)\n{\n    MAC_DATA *mdata = t->data;\n    if (strcmp(keyword, "Key") == 0)\n        return parse_bin(value, &mdata->key, &mdata->key_len);\n    if (strcmp(keyword, "IV") == 0)\n        return parse_bin(value, &mdata->iv, &mdata->iv_len);\n    if (strcmp(keyword, "Algorithm") == 0) {\n        mdata->alg = OPENSSL_strdup(value);\n        if (!mdata->alg)\n            return 0;\n        return 1;\n    }\n    if (strcmp(keyword, "Input") == 0)\n        return parse_bin(value, &mdata->input, &mdata->input_len);\n    if (strcmp(keyword, "Output") == 0)\n        return parse_bin(value, &mdata->output, &mdata->output_len);\n    if (strcmp(keyword, "Ctrl") == 0)\n        return sk_OPENSSL_STRING_push(mdata->controls,\n                                      OPENSSL_strdup(value)) != 0;\n    return 0;\n}', 'char *CRYPTO_strdup(const char *str, const char* file, int line)\n{\n    char *ret;\n    if (str == NULL)\n        return NULL;\n    ret = CRYPTO_malloc(strlen(str) + 1, file, line);\n    if (ret != NULL)\n        strcpy(ret, str);\n    return ret;\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}', 'DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)', '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}']