crypto/ex_data.c:192: error: NULL_DEREFERENCE
  pointer `global` last assigned on line 152 could be null and is dereferenced at line 192, column 26.
Showing all 17 steps of the trace


crypto/ex_data.c:144:1: start of procedure crypto_get_ex_new_index_ex()
142.    * Register a new index.
143.    */
144. > int crypto_get_ex_new_index_ex(OPENSSL_CTX *ctx, int class_index, long argl,
145.                                  void *argp, CRYPTO_EX_new *new_func,
146.                                  CRYPTO_EX_dup *dup_func,

crypto/ex_data.c:149:5: 
147.                                  CRYPTO_EX_free *free_func)
148.   {
149. >     int toret = -1;
150.       EX_CALLBACK *a;
151.       EX_CALLBACKS *ip;

crypto/ex_data.c:152:5: 
150.       EX_CALLBACK *a;
151.       EX_CALLBACKS *ip;
152. >     OSSL_EX_DATA_GLOBAL *global = openssl_ctx_get_ex_data_global(ctx);
153.   
154.       if (global == NULL)

crypto/context.c:211:1: start of procedure openssl_ctx_get_ex_data_global()
  209.   }
  210.   
  211. > OSSL_EX_DATA_GLOBAL *openssl_ctx_get_ex_data_global(OPENSSL_CTX *ctx)
  212.   {
  213.       /*

crypto/context.c:219:9: Taking true branch
  217.        */
  218.   #ifndef FIPS_MODE
  219.       if (ctx == NULL) {
                 ^
  220.           if (!RUN_ONCE(&default_context_init, do_default_context_init))
  221.               return NULL;

crypto/context.c:220:14: 
  218.   #ifndef FIPS_MODE
  219.       if (ctx == NULL) {
  220. >         if (!RUN_ONCE(&default_context_init, do_default_context_init))
  221.               return NULL;
  222.           ctx = default_context;

crypto/threads_pthread.c:111:1: start of procedure CRYPTO_THREAD_run_once()
    109.   }
    110.   
    111. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    112.   {
    113.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:113:9: Taking true branch
    111.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
    112.   {
    113.       if (pthread_once(once, init) != 0)
                   ^
    114.           return 0;
    115.   

crypto/threads_pthread.c:114:9: 
    112.   {
    113.       if (pthread_once(once, init) != 0)
    114. >         return 0;
    115.   
    116.       return 1;

crypto/threads_pthread.c:117:1: return from a call to CRYPTO_THREAD_run_once
    115.   
    116.       return 1;
    117. > }
    118.   
    119.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/context.c:220:14: Condition is false
  218.   #ifndef FIPS_MODE
  219.       if (ctx == NULL) {
  220.           if (!RUN_ONCE(&default_context_init, do_default_context_init))
                      ^
  221.               return NULL;
  222.           ctx = default_context;

crypto/context.c:220:14: Taking true branch
  218.   #ifndef FIPS_MODE
  219.       if (ctx == NULL) {
  220.           if (!RUN_ONCE(&default_context_init, do_default_context_init))
                      ^
  221.               return NULL;
  222.           ctx = default_context;

crypto/context.c:221:13: 
  219.       if (ctx == NULL) {
  220.           if (!RUN_ONCE(&default_context_init, do_default_context_init))
  221. >             return NULL;
  222.           ctx = default_context;
  223.       }

crypto/context.c:228:1: return from a call to openssl_ctx_get_ex_data_global
  226.           return NULL;
  227.       return &ctx->global;
  228. > }
  229.   
  230.   int openssl_ctx_run_once(OPENSSL_CTX *ctx, unsigned int idx,

crypto/ex_data.c:154:9: Taking true branch
152.       OSSL_EX_DATA_GLOBAL *global = openssl_ctx_get_ex_data_global(ctx);
153.   
154.       if (global == NULL)
               ^
155.           goto err;
156.   

crypto/ex_data.c:191:2: 
189.       (void)sk_EX_CALLBACK_set(ip->meth, toret, a);
190.   
191. >  err:
192.       CRYPTO_THREAD_unlock(global->ex_data_lock);
193.       return toret;

crypto/ex_data.c:192:5: 
190.   
191.    err:
192. >     CRYPTO_THREAD_unlock(global->ex_data_lock);
193.       return toret;
194.   }

int crypto_get_ex_new_index_ex(OPENSSL_CTX *ctx, int class_index, long argl,
                               void *argp, CRYPTO_EX_new *new_func,
                               CRYPTO_EX_dup *dup_func,
                               CRYPTO_EX_free *free_func)
{
    int toret = -1;
    EX_CALLBACK *a;
    EX_CALLBACKS *ip;
    OSSL_EX_DATA_GLOBAL *global = openssl_ctx_get_ex_data_global(ctx);
    if (global == NULL)
        goto err;
    ip = get_and_lock(ctx, class_index);
    if (ip == NULL)
        return -1;
    if (ip->meth == NULL) {
        ip->meth = sk_EX_CALLBACK_new_null();
        if (ip->meth == NULL
            || !sk_EX_CALLBACK_push(ip->meth, NULL)) {
            CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX_EX, ERR_R_MALLOC_FAILURE);
            goto err;
        }
    }
    a = (EX_CALLBACK *)OPENSSL_malloc(sizeof(*a));
    if (a == NULL) {
        CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX_EX, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    a->argl = argl;
    a->argp = argp;
    a->new_func = new_func;
    a->dup_func = dup_func;
    a->free_func = free_func;
    if (!sk_EX_CALLBACK_push(ip->meth, NULL)) {
        CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX_EX, ERR_R_MALLOC_FAILURE);
        OPENSSL_free(a);
        goto err;
    }
    toret = sk_EX_CALLBACK_num(ip->meth) - 1;
    (void)sk_EX_CALLBACK_set(ip->meth, toret, a);
 err:
    CRYPTO_THREAD_unlock(global->ex_data_lock);
    return toret;
}
['int crypto_get_ex_new_index_ex(OPENSSL_CTX *ctx, int class_index, long argl,\n                               void *argp, CRYPTO_EX_new *new_func,\n                               CRYPTO_EX_dup *dup_func,\n                               CRYPTO_EX_free *free_func)\n{\n    int toret = -1;\n    EX_CALLBACK *a;\n    EX_CALLBACKS *ip;\n    OSSL_EX_DATA_GLOBAL *global = openssl_ctx_get_ex_data_global(ctx);\n    if (global == NULL)\n        goto err;\n    ip = get_and_lock(ctx, class_index);\n    if (ip == NULL)\n        return -1;\n    if (ip->meth == NULL) {\n        ip->meth = sk_EX_CALLBACK_new_null();\n        if (ip->meth == NULL\n            || !sk_EX_CALLBACK_push(ip->meth, NULL)) {\n            CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX_EX, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n    }\n    a = (EX_CALLBACK *)OPENSSL_malloc(sizeof(*a));\n    if (a == NULL) {\n        CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX_EX, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    a->argl = argl;\n    a->argp = argp;\n    a->new_func = new_func;\n    a->dup_func = dup_func;\n    a->free_func = free_func;\n    if (!sk_EX_CALLBACK_push(ip->meth, NULL)) {\n        CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX_EX, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(a);\n        goto err;\n    }\n    toret = sk_EX_CALLBACK_num(ip->meth) - 1;\n    (void)sk_EX_CALLBACK_set(ip->meth, toret, a);\n err:\n    CRYPTO_THREAD_unlock(global->ex_data_lock);\n    return toret;\n}', 'OSSL_EX_DATA_GLOBAL *openssl_ctx_get_ex_data_global(OPENSSL_CTX *ctx)\n{\n#ifndef FIPS_MODE\n    if (ctx == NULL) {\n        if (!RUN_ONCE(&default_context_init, do_default_context_init))\n            return NULL;\n        ctx = default_context;\n    }\n#endif\n    if (ctx == NULL)\n        return NULL;\n    return &ctx->global;\n}', 'int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))\n{\n    if (pthread_once(once, init) != 0)\n        return 0;\n    return 1;\n}']