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:185:1: start of procedure CRYPTO_zalloc()
    183.   }
    184.   
    185. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    186.   {
    187.       void *ret = CRYPTO_malloc(num, file, line);

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

crypto/mem.c:157:1: start of procedure CRYPTO_malloc()
      155.   #endif
      156.   
      157. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      158.   {
      159.       void *ret = NULL;

crypto/mem.c:159:5: 
      157.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      158.   {
      159. >     void *ret = NULL;
      160.   
      161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:161:9: Taking false branch
      159.       void *ret = NULL;
      160.   
      161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      162.           return malloc_impl(num, file, line);
      163.   

crypto/mem.c:164:9: Taking false branch
      162.           return malloc_impl(num, file, line);
      163.   
      164.       if (num <= 0)
                     ^
      165.           return NULL;
      166.   

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

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

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

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

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

crypto/mem.c:183:1: return from a call to CRYPTO_malloc
      181.   
      182.       return ret;
      183. > }
      184.   
      185.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

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

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

crypto/mem.c:193:1: return from a call to CRYPTO_zalloc
    191.           memset(ret, 0, num);
    192.       return ret;
    193. > }
    194.   
    195.   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}']