test/evp_test.c:1284: error: NULL_DEREFERENCE
  pointer `mdat` last assigned on line 1283 could be null and is dereferenced at line 1284, column 5.
Showing all 16 steps of the trace


test/evp_test.c:1252:1: start of procedure mac_test_init()
1250.   } MAC_DATA;
1251.   
1252. > static int mac_test_init(EVP_TEST *t, const char *alg)
1253.   {
1254.       int type;

test/evp_test.c:1257:9: Taking true branch
1255.       MAC_DATA *mdat;
1256.   
1257.       if (strcmp(alg, "HMAC") == 0) {
                ^
1258.           type = EVP_PKEY_HMAC;
1259.       } else if (strcmp(alg, "CMAC") == 0) {

test/evp_test.c:1258:9: 
1256.   
1257.       if (strcmp(alg, "HMAC") == 0) {
1258. >         type = EVP_PKEY_HMAC;
1259.       } else if (strcmp(alg, "CMAC") == 0) {
1260.   #ifndef OPENSSL_NO_CMAC

test/evp_test.c:1283:5: 
1281.           return 0;
1282.   
1283. >     mdat = OPENSSL_zalloc(sizeof(*mdat));
1284.       mdat->type = type;
1285.       t->data = mdat;

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
  184.   }
  185.   
  186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  187.   {
  188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
  186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  187.   {
  188. >     void *ret = CRYPTO_malloc(num, file, line);
  189.   
  190.       FAILTEST();

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
    156.   #endif
    157.   
    158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    159.   {
    160.       void *ret = NULL;

crypto/mem.c:160:5: 
    158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    159.   {
    160. >     void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking true branch
    160.       void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    163.           return malloc_impl(num, file, line);
    164.   

crypto/mem.c:162:32: Taking true branch
    160.       void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                          ^
    163.           return malloc_impl(num, file, line);
    164.   

crypto/mem.c:163:9: Skipping __function_pointer__(): unresolved function pointer
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
    163.           return malloc_impl(num, file, line);
                   ^
    164.   
    165.       if (num == 0)

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
    182.   
    183.       return ret;
    184. > }
    185.   
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:191:9: Taking false branch
  189.   
  190.       FAILTEST();
  191.       if (ret != NULL)
                 ^
  192.           memset(ret, 0, num);
  193.       return ret;

crypto/mem.c:193:5: 
  191.       if (ret != NULL)
  192.           memset(ret, 0, num);
  193. >     return ret;
  194.   }
  195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
  192.           memset(ret, 0, num);
  193.       return ret;
  194. > }
  195.   
  196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

test/evp_test.c:1284:5: 
1282.   
1283.       mdat = OPENSSL_zalloc(sizeof(*mdat));
1284. >     mdat->type = type;
1285.       t->data = mdat;
1286.       return 1;

static int mac_test_init(EVP_TEST *t, const char *alg)
{
    int type;
    MAC_DATA *mdat;
    if (strcmp(alg, "HMAC") == 0) {
        type = EVP_PKEY_HMAC;
    } else if (strcmp(alg, "CMAC") == 0) {
#ifndef OPENSSL_NO_CMAC
        type = EVP_PKEY_CMAC;
#else
        t->skip = 1;
        return 1;
#endif
    } else if (strcmp(alg, "Poly1305") == 0) {
#ifndef OPENSSL_NO_POLY1305
        type = EVP_PKEY_POLY1305;
#else
        t->skip = 1;
        return 1;
#endif
    } else if (strcmp(alg, "SipHash") == 0) {
#ifndef OPENSSL_NO_SIPHASH
        type = EVP_PKEY_SIPHASH;
#else
        t->skip = 1;
        return 1;
#endif
    } else
        return 0;
    mdat = OPENSSL_zalloc(sizeof(*mdat));
    mdat->type = type;
    t->data = mdat;
    return 1;
}
['static int mac_test_init(EVP_TEST *t, const char *alg)\n{\n    int type;\n    MAC_DATA *mdat;\n    if (strcmp(alg, "HMAC") == 0) {\n        type = EVP_PKEY_HMAC;\n    } else if (strcmp(alg, "CMAC") == 0) {\n#ifndef OPENSSL_NO_CMAC\n        type = EVP_PKEY_CMAC;\n#else\n        t->skip = 1;\n        return 1;\n#endif\n    } else if (strcmp(alg, "Poly1305") == 0) {\n#ifndef OPENSSL_NO_POLY1305\n        type = EVP_PKEY_POLY1305;\n#else\n        t->skip = 1;\n        return 1;\n#endif\n    } else if (strcmp(alg, "SipHash") == 0) {\n#ifndef OPENSSL_NO_SIPHASH\n        type = EVP_PKEY_SIPHASH;\n#else\n        t->skip = 1;\n        return 1;\n#endif\n    } else\n        return 0;\n    mdat = OPENSSL_zalloc(sizeof(*mdat));\n    mdat->type = type;\n    t->data = mdat;\n    return 1;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\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    allow_customize = 0;\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    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']