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


test/evp_test.c:1022:1: start of procedure mac_test_init()
1020.   };
1021.   
1022. > static int mac_test_init(struct evp_test *t, const char *alg)
1023.   {
1024.       int type;

test/evp_test.c:1026:9: Taking true branch
1024.       int type;
1025.       struct mac_data *mdat;
1026.       if (strcmp(alg, "HMAC") == 0)
                ^
1027.           type = EVP_PKEY_HMAC;
1028.       else if (strcmp(alg, "CMAC") == 0)

test/evp_test.c:1027:9: 
1025.       struct mac_data *mdat;
1026.       if (strcmp(alg, "HMAC") == 0)
1027. >         type = EVP_PKEY_HMAC;
1028.       else if (strcmp(alg, "CMAC") == 0)
1029.           type = EVP_PKEY_CMAC;

test/evp_test.c:1033:5: 
1031.           return 0;
1032.   
1033. >     mdat = OPENSSL_malloc(sizeof(*mdat));
1034.       mdat->type = type;
1035.       mdat->alg = NULL;

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
  117.   }
  118.   
  119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121.       void *ret = NULL;

crypto/mem.c:121:5: 
  119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  120.   {
  121. >     void *ret = NULL;
  122.   
  123.       if (num <= 0)

crypto/mem.c:123:9: Taking false branch
  121.       void *ret = NULL;
  122.   
  123.       if (num <= 0)
                 ^
  124.           return NULL;
  125.   

crypto/mem.c:126:5: 
  124.           return NULL;
  125.   
  126. >     allow_customize = 0;
  127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
  134.       }
  135.   #else
  136. >     (void)file;
  137.       (void)line;
  138.       ret = malloc(num);

crypto/mem.c:137:5: 
  135.   #else
  136.       (void)file;
  137. >     (void)line;
  138.       ret = malloc(num);
  139.   #endif

crypto/mem.c:138:5: 
  136.       (void)file;
  137.       (void)line;
  138. >     ret = malloc(num);
  139.   #endif
  140.   

crypto/mem.c:153:5: 
  151.   #endif
  152.   
  153. >     return ret;
  154.   }
  155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
  152.   
  153.       return ret;
  154. > }
  155.   
  156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

test/evp_test.c:1034:5: 
1032.   
1033.       mdat = OPENSSL_malloc(sizeof(*mdat));
1034. >     mdat->type = type;
1035.       mdat->alg = NULL;
1036.       mdat->key = NULL;

static int mac_test_init(struct evp_test *t, const char *alg)
{
    int type;
    struct mac_data *mdat;
    if (strcmp(alg, "HMAC") == 0)
        type = EVP_PKEY_HMAC;
    else if (strcmp(alg, "CMAC") == 0)
        type = EVP_PKEY_CMAC;
    else
        return 0;
    mdat = OPENSSL_malloc(sizeof(*mdat));
    mdat->type = type;
    mdat->alg = NULL;
    mdat->key = NULL;
    mdat->input = NULL;
    mdat->output = NULL;
    t->data = mdat;
    return 1;
}
['static int mac_test_init(struct evp_test *t, const char *alg)\n{\n    int type;\n    struct mac_data *mdat;\n    if (strcmp(alg, "HMAC") == 0)\n        type = EVP_PKEY_HMAC;\n    else if (strcmp(alg, "CMAC") == 0)\n        type = EVP_PKEY_CMAC;\n    else\n        return 0;\n    mdat = OPENSSL_malloc(sizeof(*mdat));\n    mdat->type = type;\n    mdat->alg = NULL;\n    mdat->key = NULL;\n    mdat->input = NULL;\n    mdat->output = NULL;\n    t->data = mdat;\n    return 1;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\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    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}']