test/ssltest_old.c:393: error: NULL_DEREFERENCE
  pointer `alpn_selected` last assigned on line 392 could be null and is dereferenced by call to `memcpy()` at line 393, column 5.
Showing all 18 steps of the trace


test/ssltest_old.c:366:1: start of procedure cb_server_alpn()
364.   }
365.   
366. > static int cb_server_alpn(SSL *s, const unsigned char **out,
367.                             unsigned char *outlen, const unsigned char *in,
368.                             unsigned int inlen, void *arg)

test/ssltest_old.c:372:5: 
370.       unsigned char *protos;
371.       size_t protos_len;
372. >     char* alpn_str = arg;
373.   
374.       protos = next_protos_parse(&protos_len, alpn_str);

test/ssltest_old.c:374:5: Skipping next_protos_parse(): empty list of specs
372.       char* alpn_str = arg;
373.   
374.       protos = next_protos_parse(&protos_len, alpn_str);
           ^
375.       if (protos == NULL) {
376.           fprintf(stderr, "failed to parser ALPN server protocol string: %s\n",

test/ssltest_old.c:375:9: Taking false branch
373.   
374.       protos = next_protos_parse(&protos_len, alpn_str);
375.       if (protos == NULL) {
               ^
376.           fprintf(stderr, "failed to parser ALPN server protocol string: %s\n",
377.                   alpn_str);

test/ssltest_old.c:381:9: Taking false branch
379.       }
380.   
381.       if (SSL_select_next_proto
               ^
382.           ((unsigned char **)out, outlen, protos, protos_len, in,
383.            inlen) != OPENSSL_NPN_NEGOTIATED) {

test/ssltest_old.c:392:5: 
390.        * verify_alpn.
391.        */
392. >     alpn_selected = OPENSSL_malloc(*outlen);
393.       memcpy(alpn_selected, *out, *outlen);
394.       *out = alpn_selected;

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
  69.   }
  70.   
  71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73.       void *ret = NULL;

crypto/mem.c:73:5: 
  71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  72.   {
  73. >     void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking true branch
  73.       void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                ^
  76.           return malloc_impl(num, file, line);
  77.   

crypto/mem.c:75:32: Taking false branch
  73.       void *ret = NULL;
  74.   
  75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                                       ^
  76.           return malloc_impl(num, file, line);
  77.   

crypto/mem.c:78:9: Taking false branch
  76.           return malloc_impl(num, file, line);
  77.   
  78.       if (num <= 0)
                ^
  79.           return NULL;
  80.   

crypto/mem.c:81:5: 
  79.           return NULL;
  80.   
  81. >     allow_customize = 0;
  82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
  83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
  89.       }
  90.   #else
  91. >     osslargused(file); osslargused(line);
  92.       ret = malloc(num);
  93.   #endif

crypto/mem.c:91:24: 
  89.       }
  90.   #else
  91. >     osslargused(file); osslargused(line);
  92.       ret = malloc(num);
  93.   #endif

crypto/mem.c:92:5: 
  90.   #else
  91.       osslargused(file); osslargused(line);
  92. >     ret = malloc(num);
  93.   #endif
  94.   

crypto/mem.c:95:5: 
  93.   #endif
  94.   
  95. >     return ret;
  96.   }
  97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
  94.   
  95.       return ret;
  96. > }
  97.   
  98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

test/ssltest_old.c:393:5: 
391.        */
392.       alpn_selected = OPENSSL_malloc(*outlen);
393. >     memcpy(alpn_selected, *out, *outlen);
394.       *out = alpn_selected;
395.   
