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


test/evp_test.c:1420:1: start of procedure pbe_test_init()
1418.   }
1419.   
1420. > static int pbe_test_init(struct evp_test *t, const char *alg)
1421.   {
1422.       struct pbe_data *pdat;

test/evp_test.c:1423:5: 
1421.   {
1422.       struct pbe_data *pdat;
1423. >     int pbe_type = 0;
1424.   
1425.   #ifndef OPENSSL_NO_SCRYPT

test/evp_test.c:1426:9: Taking false branch
1424.   
1425.   #ifndef OPENSSL_NO_SCRYPT
1426.       if (strcmp(alg, "scrypt") == 0)
                ^
1427.           pbe_type = PBE_TYPE_SCRYPT;
1428.   #endif

test/evp_test.c:1429:14: Taking false branch
1427.           pbe_type = PBE_TYPE_SCRYPT;
1428.   #endif
1429.       else if (strcmp(alg, "pbkdf2") == 0)
                     ^
1430.           pbe_type = PBE_TYPE_PBKDF2;
1431.       else if (strcmp(alg, "pkcs12") == 0)

test/evp_test.c:1431:14: Taking false branch
1429.       else if (strcmp(alg, "pbkdf2") == 0)
1430.           pbe_type = PBE_TYPE_PBKDF2;
1431.       else if (strcmp(alg, "pkcs12") == 0)
                     ^
1432.           pbe_type = PBE_TYPE_PKCS12;
1433.       else

test/evp_test.c:1434:9: 
1432.           pbe_type = PBE_TYPE_PKCS12;
1433.       else
1434. >         fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
1435.       pdat = OPENSSL_malloc(sizeof(*pdat));
1436.       pdat->pbe_type = pbe_type;

test/evp_test.c:1435:5: 
1433.       else
1434.           fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
1435. >     pdat = OPENSSL_malloc(sizeof(*pdat));
1436.       pdat->pbe_type = pbe_type;
1437.       pdat->pass = NULL;

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

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

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

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

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

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

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

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

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

test/evp_test.c:1436:5: 
1434.           fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
1435.       pdat = OPENSSL_malloc(sizeof(*pdat));
1436. >     pdat->pbe_type = pbe_type;
1437.       pdat->pass = NULL;
1438.       pdat->salt = NULL;

static int pbe_test_init(struct evp_test *t, const char *alg)
{
    struct pbe_data *pdat;
    int pbe_type = 0;
#ifndef OPENSSL_NO_SCRYPT
    if (strcmp(alg, "scrypt") == 0)
        pbe_type = PBE_TYPE_SCRYPT;
#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#ifndef OPENSSL_NO_SCRYPT\n    if (strcmp(alg, "scrypt") == 0)\n        pbe_type = PBE_TYPE_SCRYPT;\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    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 (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}']