crypto/ct/ct_log.c:201: error: NULL_DEREFERENCE
  pointer `load_ctx` last assigned on line 199 could be null and is dereferenced at line 201, column 5.
Showing all 25 steps of the trace


crypto/ct/ct_log.c:195:1: start of procedure CTLOG_STORE_load_file()
193.   }
194.   
195. > int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)
196.   {
197.       int ret = 0;

crypto/ct/ct_log.c:197:5: 
195.   int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)
196.   {
197. >     int ret = 0;
198.       char *enabled_logs;
199.       CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();

crypto/ct/ct_log.c:199:5: 
197.       int ret = 0;
198.       char *enabled_logs;
199. >     CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();
200.   
201.       load_ctx->log_store = store;

crypto/ct/ct_log.c:57:1: start of procedure ctlog_store_load_ctx_new()
  55.   static void ctlog_store_load_ctx_free(CTLOG_STORE_LOAD_CTX* ctx);
  56.   
  57. > static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new()
  58.   {
  59.       CTLOG_STORE_LOAD_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/ct/ct_log.c:59:5: 
  57.   static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new()
  58.   {
  59. >     CTLOG_STORE_LOAD_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  60.   
  61.       if (ctx == NULL)

crypto/mem.c:186:1: start of procedure CRYPTO_zalloc()
    184.   }
    185.   
    186. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:188:5: 
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    187.   {
    188. >     void *ret = CRYPTO_malloc(num, file, line);
    189.   
    190.       FAILTEST();

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)

crypto/mem.c:191:9: Taking false branch
    189.   
    190.       FAILTEST();
    191.       if (ret != NULL)
                   ^
    192.           memset(ret, 0, num);
    193.       return ret;

crypto/mem.c:193:5: 
    191.       if (ret != NULL)
    192.           memset(ret, 0, num);
    193. >     return ret;
    194.   }
    195.   

crypto/mem.c:194:1: return from a call to CRYPTO_zalloc
    192.           memset(ret, 0, num);
    193.       return ret;
    194. > }
    195.   
    196.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:61:9: Taking true branch
  59.       CTLOG_STORE_LOAD_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  60.   
  61.       if (ctx == NULL)
                ^
  62.           CTerr(CT_F_CTLOG_STORE_LOAD_CTX_NEW, ERR_R_MALLOC_FAILURE);
  63.   

crypto/ct/ct_log.c:62:9: Skipping ERR_put_error(): empty list of specs
  60.   
  61.       if (ctx == NULL)
  62.           CTerr(CT_F_CTLOG_STORE_LOAD_CTX_NEW, ERR_R_MALLOC_FAILURE);
                ^
  63.   
  64.       return ctx;

crypto/ct/ct_log.c:64:5: 
  62.           CTerr(CT_F_CTLOG_STORE_LOAD_CTX_NEW, ERR_R_MALLOC_FAILURE);
  63.   
  64. >     return ctx;
  65.   }
  66.   

crypto/ct/ct_log.c:65:1: return from a call to ctlog_store_load_ctx_new
  63.   
  64.       return ctx;
  65. > }
  66.   
  67.   static void ctlog_store_load_ctx_free(CTLOG_STORE_LOAD_CTX* ctx)

crypto/ct/ct_log.c:201:5: 
199.       CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();
200.   
201. >     load_ctx->log_store = store;
202.       load_ctx->conf = NCONF_new(NULL);
203.       if (load_ctx->conf == NULL)

int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)
{
    int ret = 0;
    char *enabled_logs;
    CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();
    load_ctx->log_store = store;
    load_ctx->conf = NCONF_new(NULL);
    if (load_ctx->conf == NULL)
        goto end;
    if (NCONF_load(load_ctx->conf, file, NULL) <= 0) {
        CTerr(CT_F_CTLOG_STORE_LOAD_FILE, CT_R_LOG_CONF_INVALID);
        goto end;
    }
    enabled_logs = NCONF_get_string(load_ctx->conf, NULL, "enabled_logs");
    if (enabled_logs == NULL) {
        CTerr(CT_F_CTLOG_STORE_LOAD_FILE, CT_R_LOG_CONF_INVALID);
        goto end;
    }
    if (!CONF_parse_list(enabled_logs, ',', 1, ctlog_store_load_log, load_ctx) ||
        load_ctx->invalid_log_entries > 0) {
        CTerr(CT_F_CTLOG_STORE_LOAD_FILE, CT_R_LOG_CONF_INVALID);
        goto end;
    }
    ret = 1;
end:
    NCONF_free(load_ctx->conf);
    ctlog_store_load_ctx_free(load_ctx);
    return ret;
}
['int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)\n{\n    int ret = 0;\n    char *enabled_logs;\n    CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();\n    load_ctx->log_store = store;\n    load_ctx->conf = NCONF_new(NULL);\n    if (load_ctx->conf == NULL)\n        goto end;\n    if (NCONF_load(load_ctx->conf, file, NULL) <= 0) {\n        CTerr(CT_F_CTLOG_STORE_LOAD_FILE, CT_R_LOG_CONF_INVALID);\n        goto end;\n    }\n    enabled_logs = NCONF_get_string(load_ctx->conf, NULL, "enabled_logs");\n    if (enabled_logs == NULL) {\n        CTerr(CT_F_CTLOG_STORE_LOAD_FILE, CT_R_LOG_CONF_INVALID);\n        goto end;\n    }\n    if (!CONF_parse_list(enabled_logs, \',\', 1, ctlog_store_load_log, load_ctx) ||\n        load_ctx->invalid_log_entries > 0) {\n        CTerr(CT_F_CTLOG_STORE_LOAD_FILE, CT_R_LOG_CONF_INVALID);\n        goto end;\n    }\n    ret = 1;\nend:\n    NCONF_free(load_ctx->conf);\n    ctlog_store_load_ctx_free(load_ctx);\n    return ret;\n}', 'static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new()\n{\n    CTLOG_STORE_LOAD_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));\n    if (ctx == NULL)\n        CTerr(CT_F_CTLOG_STORE_LOAD_CTX_NEW, ERR_R_MALLOC_FAILURE);\n    return ctx;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\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}']