apps/s_cb.c:936: error: NULL_DEREFERENCE
  pointer `exc` last assigned on line 934 could be null and is dereferenced by call to `memset()` at line 936, column 5.
Showing all 19 steps of the trace


apps/s_cb.c:932:1: start of procedure ssl_excert_prepend()
930.   }
931.   
932. > static int ssl_excert_prepend(SSL_EXCERT **pexc)
933.   {
934.       SSL_EXCERT *exc = app_malloc(sizeof(*exc), "prepend cert");

apps/s_cb.c:934:5: 
932.   static int ssl_excert_prepend(SSL_EXCERT **pexc)
933.   {
934. >     SSL_EXCERT *exc = app_malloc(sizeof(*exc), "prepend cert");
935.   
936.       memset(exc, 0, sizeof(*exc));

test/testutil/apps_mem.c:14:1: start of procedure app_malloc()
  12.   /* shim that avoids sucking in too much from apps/apps.c */
  13.   
  14. > void* app_malloc(int sz, const char *what)
  15.   {
  16.       void *vp = OPENSSL_malloc(sz);

test/testutil/apps_mem.c:16:5: 
  14.   void* app_malloc(int sz, const char *what)
  15.   {
  16. >     void *vp = OPENSSL_malloc(sz);
  17.   
  18.       return vp;

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
    190.   #endif
    191.   
    192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194.       void *ret = NULL;

crypto/mem.c:194:5: 
    192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194. >     void *ret = NULL;
    195.   
    196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking true branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:197:32: Taking false branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                          ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:200:9: Taking false branch
    198.           return malloc_impl(num, file, line);
    199.   
    200.       if (num == 0)
                   ^
    201.           return NULL;
    202.   

crypto/mem.c:204:9: Taking true branch
    202.   
    203.       FAILTEST();
    204.       if (allow_customize) {
                   ^
    205.           /*
    206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
    208.            * allocation.
    209.            */
    210. >         allow_customize = 0;
    211.       }
    212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

crypto/mem.c:221:5: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:221:19: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:222:5: 
    220.   #else
    221.       (void)(file); (void)(line);
    222. >     ret = malloc(num);
    223.   #endif
    224.   

crypto/mem.c:225:5: 
    223.   #endif
    224.   
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
    224.   
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

test/testutil/apps_mem.c:18:5: 
  16.       void *vp = OPENSSL_malloc(sz);
  17.   
  18. >     return vp;
  19.   }

test/testutil/apps_mem.c:19:1: return from a call to app_malloc
  17.   
  18.       return vp;
  19. > }

apps/s_cb.c:936:5: 
934.       SSL_EXCERT *exc = app_malloc(sizeof(*exc), "prepend cert");
935.   
936. >     memset(exc, 0, sizeof(*exc));
937.   
938.       exc->next = *pexc;

static int ssl_excert_prepend(SSL_EXCERT **pexc)
{
    SSL_EXCERT *exc = app_malloc(sizeof(*exc), "prepend cert");
    memset(exc, 0, sizeof(*exc));
    exc->next = *pexc;
    *pexc = exc;
    if (exc->next) {
        exc->certform = exc->next->certform;
        exc->keyform = exc->next->keyform;
        exc->next->prev = exc;
    } else {
        exc->certform = FORMAT_PEM;
        exc->keyform = FORMAT_PEM;
    }
    return 1;
}
['static int ssl_excert_prepend(SSL_EXCERT **pexc)\n{\n    SSL_EXCERT *exc = app_malloc(sizeof(*exc), "prepend cert");\n    memset(exc, 0, sizeof(*exc));\n    exc->next = *pexc;\n    *pexc = exc;\n    if (exc->next) {\n        exc->certform = exc->next->certform;\n        exc->keyform = exc->next->keyform;\n        exc->next->prev = exc;\n    } else {\n        exc->certform = FORMAT_PEM;\n        exc->keyform = FORMAT_PEM;\n    }\n    return 1;\n}', 'void* app_malloc(int sz, const char *what)\n{\n    void *vp = OPENSSL_malloc(sz);\n    return vp;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\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    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']