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


test/evp_test.c:1201:1: start of procedure mac_test_init()
1199.   };
1200.   
1201. > static int mac_test_init(struct evp_test *t, const char *alg)
1202.   {
1203.       int type;

test/evp_test.c:1205:9: Taking true branch
1203.       int type;
1204.       struct mac_data *mdat;
1205.       if (strcmp(alg, "HMAC") == 0) {
                ^
1206.           type = EVP_PKEY_HMAC;
1207.       } else if (strcmp(alg, "CMAC") == 0) {

test/evp_test.c:1206:9: 
1204.       struct mac_data *mdat;
1205.       if (strcmp(alg, "HMAC") == 0) {
1206. >         type = EVP_PKEY_HMAC;
1207.       } else if (strcmp(alg, "CMAC") == 0) {
1208.   #ifndef OPENSSL_NO_CMAC

test/evp_test.c:1231:5: 
1229.           return 0;
1230.   
1231. >     mdat = OPENSSL_malloc(sizeof(*mdat));
1232.       mdat->type = type;
1233.       mdat->alg = NULL;

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 false 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:165:9: Taking false branch
  163.           return malloc_impl(num, file, line);
  164.   
  165.       if (num == 0)
                 ^
  166.           return NULL;
  167.   

crypto/mem.c:169:5: 
  167.   
  168.       FAILTEST();
  169. >     allow_customize = 0;
  170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
  177.       }
  178.   #else
  179. >     osslargused(file); osslargused(line);
  180.       ret = malloc(num);
  181.   #endif

crypto/mem.c:179:24: 
  177.       }
  178.   #else
  179. >     osslargused(file); osslargused(line);
  180.       ret = malloc(num);
  181.   #endif

crypto/mem.c:180:5: 
  178.   #else
  179.       osslargused(file); osslargused(line);
  180. >     ret = malloc(num);
  181.   #endif
  182.   

crypto/mem.c:183:5: 
  181.   #endif
  182.   
  183. >     return ret;
  184.   }
  185.   

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)

test/evp_test.c:1232:5: 
1230.   
1231.       mdat = OPENSSL_malloc(sizeof(*mdat));
1232. >     mdat->type = type;
1233.       mdat->alg = NULL;
1234.       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) {
#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_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#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_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 (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}']