test/evp_test.c:1725: error: NULL_DEREFERENCE
  pointer `pdat` last assigned on line 1724 could be null and is dereferenced at line 1725, column 5.
Showing all 18 steps of the trace


test/evp_test.c:1705:1: start of procedure pbe_test_init()
1703.   }
1704.   
1705. > static int pbe_test_init(struct evp_test *t, const char *alg)
1706.   {
1707.       struct pbe_data *pdat;

test/evp_test.c:1708:5: 
1706.   {
1707.       struct pbe_data *pdat;
1708. >     int pbe_type = 0;
1709.   
1710.       if (strcmp(alg, "scrypt") == 0) {

test/evp_test.c:1710:9: Taking false branch
1708.       int pbe_type = 0;
1709.   
1710.       if (strcmp(alg, "scrypt") == 0) {
                ^
1711.   #ifndef OPENSSL_NO_SCRYPT
1712.           pbe_type = PBE_TYPE_SCRYPT;

test/evp_test.c:1717:16: Taking false branch
1715.           return 1;
1716.   #endif
1717.       } else if (strcmp(alg, "pbkdf2") == 0) {
                       ^
1718.           pbe_type = PBE_TYPE_PBKDF2;
1719.       } else if (strcmp(alg, "pkcs12") == 0) {

test/evp_test.c:1719:16: Taking false branch
1717.       } else if (strcmp(alg, "pbkdf2") == 0) {
1718.           pbe_type = PBE_TYPE_PBKDF2;
1719.       } else if (strcmp(alg, "pkcs12") == 0) {
                       ^
1720.           pbe_type = PBE_TYPE_PKCS12;
1721.       } else {

test/evp_test.c:1722:9: 
1720.           pbe_type = PBE_TYPE_PKCS12;
1721.       } else {
1722. >         fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
1723.       }
1724.       pdat = OPENSSL_malloc(sizeof(*pdat));

test/evp_test.c:1724:5: 
1722.           fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
1723.       }
1724. >     pdat = OPENSSL_malloc(sizeof(*pdat));
1725.       pdat->pbe_type = pbe_type;
1726.       pdat->pass = 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:1725:5: 
1723.       }
1724.       pdat = OPENSSL_malloc(sizeof(*pdat));
1725. >     pdat->pbe_type = pbe_type;
1726.       pdat->pass = NULL;
1727.       pdat->salt = NULL;

static int pbe_test_init(struct evp_test *t, const char *alg)
{
    struct pbe_data *pdat;
    int pbe_type = 0;
    if (strcmp(alg, "scrypt") == 0) {
#ifndef OPENSSL_NO_SCRYPT
        pbe_type = PBE_TYPE_SCRYPT;
#else
        t->skip = 1;
        return 1;
#endif
    } else if (strcmp(alg, "pbkdf2") == 0) {
        pbe_type = PBE_TYPE_PBKDF2;
    } else if (strcmp(alg, "pkcs12") == 0) {
        pbe_type = PBE_TYPE_PKCS12;
    } else {
        fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
    }
    pdat = OPENSSL_malloc(sizeof(*pdat));
    pdat->pbe_type = pbe_type;
    pdat->pass = NULL;
    pdat->salt = NULL;
    pdat->N = 0;
    pdat->r = 0;
    pdat->p = 0;
    pdat->maxmem = 0;
    pdat->id = 0;
    pdat->iter = 0;
    pdat->md = NULL;
    t->data = pdat;
    return 1;
}
['static int pbe_test_init(struct evp_test *t, const char *alg)\n{\n    struct pbe_data *pdat;\n    int pbe_type = 0;\n    if (strcmp(alg, "scrypt") == 0) {\n#ifndef OPENSSL_NO_SCRYPT\n        pbe_type = PBE_TYPE_SCRYPT;\n#else\n        t->skip = 1;\n        return 1;\n#endif\n    } else if (strcmp(alg, "pbkdf2") == 0) {\n        pbe_type = PBE_TYPE_PBKDF2;\n    } else if (strcmp(alg, "pkcs12") == 0) {\n        pbe_type = PBE_TYPE_PKCS12;\n    } else {\n        fprintf(stderr, "Unknown pbe algorithm %s\\n", alg);\n    }\n    pdat = OPENSSL_malloc(sizeof(*pdat));\n    pdat->pbe_type = pbe_type;\n    pdat->pass = NULL;\n    pdat->salt = NULL;\n    pdat->N = 0;\n    pdat->r = 0;\n    pdat->p = 0;\n    pdat->maxmem = 0;\n    pdat->id = 0;\n    pdat->iter = 0;\n    pdat->md = NULL;\n    t->data = pdat;\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}']