From 4e8b5940020b6097f5941a243be6d9eeb41ba4d2 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Fri, 20 Sep 2019 19:12:31 +0200 Subject: [PATCH] Fix uninitialized variable in an edge case If `context_buf = mbedtls_calloc( 1, buf_len )` failed, `context_buf_len` was not initialized. Noticed by `gcc -Os -Werror=maybe-uninitialized`. This was only a problem in ssl_server2 (a test program), only with MBEDTLS_SSL_CONTEXT_SERIALIZATION enabled. --- programs/ssl/ssl_server2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 27f231230..d23a700f8 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1820,7 +1820,7 @@ int main( int argc, char *argv[] ) #endif #if defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION) unsigned char *context_buf = NULL; - size_t context_buf_len; + size_t context_buf_len = 0; #endif int i;