crypto/initthread.c:233: error: NULL_DEREFERENCE
  pointer `local` last assigned on line 220 could be null and is dereferenced by call to `init_get_thread_local()` at line 233, column 13.
Showing all 17 steps of the trace


crypto/initthread.c:208:1: start of procedure ossl_init_thread_start()
206.   }
207.   
208. > int ossl_init_thread_start(void *arg, OSSL_thread_stop_handler_fn handfn)
209.   {
210.       THREAD_EVENT_HANDLER **hands;

crypto/initthread.c:213:5: 
211.       THREAD_EVENT_HANDLER *hand;
212.   #ifdef FIPS_MODE
213. >     OPENSSL_CTX *ctx = arg;
214.   
215.       /*

crypto/initthread.c:220:5: 
218.        * gets informed about thread stop events individually.
219.        */
220. >     CRYPTO_THREAD_LOCAL *local
221.           = openssl_ctx_get_data(ctx, OPENSSL_CTX_THREAD_EVENT_HANDLER_INDEX,
222.                                  &thread_event_ossl_ctx_method);

crypto/context.c:186:1: start of procedure openssl_ctx_get_data()
  184.   }
  185.   
  186. > void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index,
  187.                              const OPENSSL_CTX_METHOD *meth)
  188.   {

crypto/context.c:189:5: 
  187.                              const OPENSSL_CTX_METHOD *meth)
  188.   {
  189. >     void *data = NULL;
  190.   
  191.       ctx = openssl_ctx_get_concrete(ctx);

crypto/context.c:191:5: 
  189.       void *data = NULL;
  190.   
  191. >     ctx = openssl_ctx_get_concrete(ctx);
  192.       if (ctx == NULL)
  193.           return NULL;

crypto/context.c:134:1: start of procedure openssl_ctx_get_concrete()
    132.   }
    133.   
    134. > OPENSSL_CTX *openssl_ctx_get_concrete(OPENSSL_CTX *ctx)
    135.   {
    136.   #ifndef FIPS_MODE

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

crypto/context.c:144:1: return from a call to openssl_ctx_get_concrete
    142.   #endif
    143.       return ctx;
    144. > }
    145.   
    146.   static void openssl_ctx_generic_new(void *parent_ign, void *ptr_ign,

crypto/context.c:192:9: Taking true branch
  190.   
  191.       ctx = openssl_ctx_get_concrete(ctx);
  192.       if (ctx == NULL)
                 ^
  193.           return NULL;
  194.   

crypto/context.c:193:9: 
  191.       ctx = openssl_ctx_get_concrete(ctx);
  192.       if (ctx == NULL)
  193. >         return NULL;
  194.   
  195.       CRYPTO_THREAD_read_lock(ctx->lock);

crypto/context.c:211:1: return from a call to openssl_ctx_get_data
  209.   
  210.       return data;
  211. > }
  212.   
  213.   OSSL_EX_DATA_GLOBAL *openssl_ctx_get_ex_data_global(OPENSSL_CTX *ctx)

crypto/initthread.c:233:5: 
231.   #endif
232.   
233. >     hands = init_get_thread_local(local, 1, 0);
234.       if (hands == NULL)
235.           return 0;

crypto/initthread.c:40:1: start of procedure init_get_thread_local()
  38.   static void init_thread_stop(void *arg, THREAD_EVENT_HANDLER **hands);
  39.   
  40. > static THREAD_EVENT_HANDLER **
  41.   init_get_thread_local(CRYPTO_THREAD_LOCAL *local, int alloc, int keep)
  42.   {

crypto/initthread.c:43:5: 
  41.   init_get_thread_local(CRYPTO_THREAD_LOCAL *local, int alloc, int keep)
  42.   {
  43. >     THREAD_EVENT_HANDLER **hands = CRYPTO_THREAD_get_local(local);
  44.   
  45.       if (alloc) {

crypto/threads_pthread.c:127:1: start of procedure CRYPTO_THREAD_get_local()
    125.   }
    126.   
    127. > void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
    128.   {
    129.       return pthread_getspecific(*key);

crypto/threads_pthread.c:129:5: Skipping pthread_getspecific(): method has no implementation
    127.   void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
    128.   {
    129.       return pthread_getspecific(*key);
               ^
    130.   }
    131.   

int ossl_init_thread_start(void *arg, OSSL_thread_stop_handler_fn handfn)
{
    THREAD_EVENT_HANDLER **hands;
    THREAD_EVENT_HANDLER *hand;
#ifdef FIPS_MODE
    OPENSSL_CTX *ctx = arg;
    CRYPTO_THREAD_LOCAL *local
        = openssl_ctx_get_data(ctx, OPENSSL_CTX_THREAD_EVENT_HANDLER_INDEX,
                               &thread_event_ossl_ctx_method);
#else
    CRYPTO_THREAD_LOCAL *local = &destructor_key.value;
#endif
    hands = init_get_thread_local(local, 1, 0);
    if (hands == NULL)
        return 0;
#ifdef FIPS_MODE
    if (*hands == NULL) {
        if (!c_thread_start(FIPS_get_provider(ctx), ossl_ctx_thread_stop))
            return 0;
    }
#endif
    hand = OPENSSL_malloc(sizeof(*hand));
    if (hand == NULL)
        return 0;
    hand->handfn = handfn;
    hand->arg = arg;
    hand->next = *hands;
    *hands = hand;
    return 1;
}
['int ossl_init_thread_start(void *arg, OSSL_thread_stop_handler_fn handfn)\n{\n    THREAD_EVENT_HANDLER **hands;\n    THREAD_EVENT_HANDLER *hand;\n#ifdef FIPS_MODE\n    OPENSSL_CTX *ctx = arg;\n    CRYPTO_THREAD_LOCAL *local\n        = openssl_ctx_get_data(ctx, OPENSSL_CTX_THREAD_EVENT_HANDLER_INDEX,\n                               &thread_event_ossl_ctx_method);\n#else\n    CRYPTO_THREAD_LOCAL *local = &destructor_key.value;\n#endif\n    hands = init_get_thread_local(local, 1, 0);\n    if (hands == NULL)\n        return 0;\n#ifdef FIPS_MODE\n    if (*hands == NULL) {\n        if (!c_thread_start(FIPS_get_provider(ctx), ossl_ctx_thread_stop))\n            return 0;\n    }\n#endif\n    hand = OPENSSL_malloc(sizeof(*hand));\n    if (hand == NULL)\n        return 0;\n    hand->handfn = handfn;\n    hand->arg = arg;\n    hand->next = *hands;\n    *hands = hand;\n    return 1;\n}', 'void *openssl_ctx_get_data(OPENSSL_CTX *ctx, int index,\n                           const OPENSSL_CTX_METHOD *meth)\n{\n    void *data = NULL;\n    ctx = openssl_ctx_get_concrete(ctx);\n    if (ctx == NULL)\n        return NULL;\n    CRYPTO_THREAD_read_lock(ctx->lock);\n    if (ctx->dyn_indexes[index] == -1\n            && !openssl_ctx_init_index(ctx, index, meth)) {\n        CRYPTO_THREAD_unlock(ctx->lock);\n        return NULL;\n    }\n    if (CRYPTO_alloc_ex_data(CRYPTO_EX_INDEX_OPENSSL_CTX, NULL,\n                             &ctx->data, ctx->dyn_indexes[index]))\n        data = CRYPTO_get_ex_data(&ctx->data, ctx->dyn_indexes[index]);\n    CRYPTO_THREAD_unlock(ctx->lock);\n    return data;\n}', 'OPENSSL_CTX *openssl_ctx_get_concrete(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 0;\n        return default_context;\n    }\n#endif\n    return ctx;\n}', 'static THREAD_EVENT_HANDLER **\ninit_get_thread_local(CRYPTO_THREAD_LOCAL *local, int alloc, int keep)\n{\n    THREAD_EVENT_HANDLER **hands = CRYPTO_THREAD_get_local(local);\n    if (alloc) {\n        if (hands == NULL\n            && (hands = OPENSSL_zalloc(sizeof(*hands))) != NULL\n            && !CRYPTO_THREAD_set_local(local, hands)) {\n            OPENSSL_free(hands);\n            return NULL;\n        }\n    } else if (!keep) {\n        CRYPTO_THREAD_set_local(local, NULL);\n    }\n    return hands;\n}', 'void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)\n{\n    return pthread_getspecific(*key);\n}']