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


crypto/ct/ct_log.c:220:1: start of procedure CTLOG_STORE_load_file()
218.   }
219.   
220. > int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)
221.   {
222.       int ret = -1;

crypto/ct/ct_log.c:222:5: 
220.   int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)
221.   {
222. >     int ret = -1;
223.       char *enabled_logs;
224.       CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();

crypto/ct/ct_log.c:224:5: 
222.       int ret = -1;
223.       char *enabled_logs;
224. >     CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();
225.   
226.       load_ctx->log_store = store;

crypto/ct/ct_log.c:102:1: start of procedure ctlog_store_load_ctx_new()
  100.   static void ctlog_store_load_ctx_free(CTLOG_STORE_LOAD_CTX* ctx);
  101.   
  102. > static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new()
  103.   {
  104.       CTLOG_STORE_LOAD_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/ct/ct_log.c:104:5: 
  102.   static CTLOG_STORE_LOAD_CTX *ctlog_store_load_ctx_new()
  103.   {
  104. >     CTLOG_STORE_LOAD_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  105.   
  106.       if (ctx == NULL) {

crypto/mem.c:146:1: start of procedure CRYPTO_zalloc()
    144.   }
    145.   
    146. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:148:5: 
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    147.   {
    148. >     void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != 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 (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                     ^
      124.           return malloc_impl(num, file, line);
      125.   

crypto/mem.c:126:9: Taking false branch
      124.           return malloc_impl(num, file, line);
      125.   
      126.       if (num <= 0)
                     ^
      127.           return NULL;
      128.   

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

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

crypto/mem.c:139:24: 
      137.       }
      138.   #else
      139. >     osslargused(file); osslargused(line);
      140.       ret = malloc(num);
      141.   #endif

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

crypto/mem.c:143:5: 
      141.   #endif
      142.   
      143. >     return ret;
      144.   }
      145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
      142.   
      143.       return ret;
      144. > }
      145.   
      146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:150:9: Taking false branch
    148.       void *ret = CRYPTO_malloc(num, file, line);
    149.   
    150.       if (ret != NULL)
                   ^
    151.           memset(ret, 0, num);
    152.       return ret;

crypto/mem.c:152:5: 
    150.       if (ret != NULL)
    151.           memset(ret, 0, num);
    152. >     return ret;
    153.   }
    154.   

crypto/mem.c:153:1: return from a call to CRYPTO_zalloc
    151.           memset(ret, 0, num);
    152.       return ret;
    153. > }
    154.   
    155.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:106:9: Taking true branch
  104.       CTLOG_STORE_LOAD_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  105.   
  106.       if (ctx == NULL) {
                 ^
  107.           CTerr(CT_F_CTLOG_STORE_LOAD_CTX_NEW, ERR_R_MALLOC_FAILURE);
  108.           goto err;

crypto/ct/ct_log.c:107:9: Skipping ERR_put_error(): empty list of specs
  105.   
  106.       if (ctx == NULL) {
  107.           CTerr(CT_F_CTLOG_STORE_LOAD_CTX_NEW, ERR_R_MALLOC_FAILURE);
                 ^
  108.           goto err;
  109.       }

crypto/ct/ct_log.c:112:1: 
  110.   
  111.       return ctx;
  112. > err:
  113.       ctlog_store_load_ctx_free(ctx);
  114.       return NULL;

crypto/ct/ct_log.c:113:5: 
  111.       return ctx;
  112.   err:
  113. >     ctlog_store_load_ctx_free(ctx);
  114.       return NULL;
  115.   }

crypto/ct/ct_log.c:117:1: start of procedure ctlog_store_load_ctx_free()
    115.   }
    116.   
    117. > static void ctlog_store_load_ctx_free(CTLOG_STORE_LOAD_CTX* ctx)
    118.   {
    119.       OPENSSL_free(ctx);

crypto/ct/ct_log.c:119:5: 
    117.   static void ctlog_store_load_ctx_free(CTLOG_STORE_LOAD_CTX* ctx)
    118.   {
    119. >     OPENSSL_free(ctx);
    120.   }
    121.   

crypto/mem.c:210:1: start of procedure CRYPTO_free()
      208.   }
      209.   
      210. > void CRYPTO_free(void *str, const char *file, int line)
      211.   {
      212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:212:9: Taking false branch
      210.   void CRYPTO_free(void *str, const char *file, int line)
      211.   {
      212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                     ^
      213.           free_impl(str, file, line);
      214.           return;

crypto/mem.c:226:5: 
      224.       }
      225.   #else
      226. >     free(str);
      227.   #endif
      228.   }

crypto/mem.c:228:1: return from a call to CRYPTO_free
      226.       free(str);
      227.   #endif
      228. > }
      229.   
      230.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/ct/ct_log.c:120:1: return from a call to ctlog_store_load_ctx_free
    118.   {
    119.       OPENSSL_free(ctx);
    120. > }
    121.   
    122.   /* Converts a log's public key into a SHA256 log ID */

crypto/ct/ct_log.c:114:5: 
  112.   err:
  113.       ctlog_store_load_ctx_free(ctx);
  114. >     return NULL;
  115.   }
  116.   

crypto/ct/ct_log.c:115:1: return from a call to ctlog_store_load_ctx_new
  113.       ctlog_store_load_ctx_free(ctx);
  114.       return NULL;
  115. > }
  116.   
  117.   static void ctlog_store_load_ctx_free(CTLOG_STORE_LOAD_CTX* ctx)

crypto/ct/ct_log.c:226:5: 
224.       CTLOG_STORE_LOAD_CTX* load_ctx = ctlog_store_load_ctx_new();
225.   
226. >     load_ctx->log_store = store;
227.       load_ctx->conf = NCONF_new(NULL);
228.       if (load_ctx->conf == NULL)

int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file)
{
    int ret = -1;
    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;
    ret = NCONF_load(load_ctx->conf, file, NULL);
    if (ret <= 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");
    CONF_parse_list(enabled_logs, ',', 1, ctlog_store_load_log, load_ctx);
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 = -1;\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    ret = NCONF_load(load_ctx->conf, file, NULL);\n    if (ret <= 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    CONF_parse_list(enabled_logs, \',\', 1, ctlog_store_load_log, load_ctx);\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        goto err;\n    }\n    return ctx;\nerr:\n    ctlog_store_load_ctx_free(ctx);\n    return NULL;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\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    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}', 'static void ctlog_store_load_ctx_free(CTLOG_STORE_LOAD_CTX* ctx)\n{\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']