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


test/evp_test.c:1494:1: start of procedure pbe_test_init()
1492.   }
1493.   
1494. > static int pbe_test_init(struct evp_test *t, const char *alg)
1495.   {
1496.       struct pbe_data *pdat;

test/evp_test.c:1497:5: 
1495.   {
1496.       struct pbe_data *pdat;
1497. >     int pbe_type = 0;
1498.   
1499.   #ifndef OPENSSL_NO_SCRYPT

test/evp_test.c:1500:9: Taking false branch
1498.   
1499.   #ifndef OPENSSL_NO_SCRYPT
1500.       if (strcmp(alg, "scrypt") == 0)
                ^
1501.           pbe_type = PBE_TYPE_SCRYPT;
1502.   #endif

test/evp_test.c:1503:14: Taking false branch
1501.           pbe_type = PBE_TYPE_SCRYPT;
1502.   #endif
1503.       else if (strcmp(alg, "pbkdf2") == 0)
                     ^
1504.           pbe_type = PBE_TYPE_PBKDF2;
1505.       else if (strcmp(alg, "pkcs12") == 0)

test/evp_test.c:1505:14: Taking false branch
1503.       else if (strcmp(alg, "pbkdf2") == 0)
1504.           pbe_type = PBE_TYPE_PBKDF2;
1505.       else if (strcmp(alg, "pkcs12") == 0)
                     ^
1506.           pbe_type = PBE_TYPE_PKCS12;
1507.       else

test/evp_test.c:1508:9: 
1506.           pbe_type = PBE_TYPE_PKCS12;
1507.       else
1508. >         fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
1509.       pdat = OPENSSL_malloc(sizeof(*pdat));
1510.       pdat->pbe_type = pbe_type;

test/evp_test.c:1509:5: 
1507.       else
1508.           fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
1509. >     pdat = OPENSSL_malloc(sizeof(*pdat));
1510.       pdat->pbe_type = pbe_type;
1511.       pdat->pass = 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:1510:5: 
1508.           fprintf(stderr, "Unknown pbe algorithm %s\n", alg);
1509.       pdat = OPENSSL_malloc(sizeof(*pdat));
1510. >     pdat->pbe_type = pbe_type;
1511.       pdat->pass = NULL;
1512.       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}']