From 19f0769ec494ade6cbf8d8451ca7e31adaac168d Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 1 Apr 2016 10:55:01 -0700 Subject: [PATCH] Fix for scan-build warning where async changes make it appear like the output buffer could be NULL (even though its not). Added NULL check on the AddRecordHeader function. --- src/internal.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/internal.c b/src/internal.c index b48343699..de74ae50b 100755 --- a/src/internal.c +++ b/src/internal.c @@ -3532,6 +3532,9 @@ static void AddRecordHeader(byte* output, word32 length, byte type, WOLFSSL* ssl /* record layer header */ rl = (RecordLayerHeader*)output; + if (rl == NULL) { + return; + } rl->type = type; rl->pvMajor = ssl->version.major; /* type and version same in each */ rl->pvMinor = ssl->version.minor; @@ -3539,13 +3542,15 @@ static void AddRecordHeader(byte* output, word32 length, byte type, WOLFSSL* ssl #ifdef WOLFSSL_ALTERNATIVE_DOWNGRADE if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->options.connectState == CONNECT_BEGIN - && !ssl->options.resuming) + && !ssl->options.resuming) { rl->pvMinor = ssl->options.downgrade ? ssl->options.minDowngrade : ssl->version.minor; + } #endif - if (!ssl->options.dtls) + if (!ssl->options.dtls) { c16toa((word16)length, rl->length); + } else { #ifdef WOLFSSL_DTLS DtlsRecordLayerHeader* dtls;