From 32e5407b433eb0d2147c1e4d5dd2f2439fbb6fe8 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 21 Feb 2019 12:20:25 +0100 Subject: [PATCH] Ignore INVALID_HANDLE_VALUE during clang scanbuild runs. The value INVALID_HANDLE_VALUE could in theory be a valid memory address, so the analyzer is confused and thinks either we have a memroy leak or we try to free a fixed address. --- winpr/libwinpr/handle/handle.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/winpr/libwinpr/handle/handle.h b/winpr/libwinpr/handle/handle.h index fc49e64..0723643 100644 --- a/winpr/libwinpr/handle/handle.h +++ b/winpr/libwinpr/handle/handle.h @@ -123,9 +123,16 @@ static INLINE BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, WINPR_HANDL { WINPR_HANDLE* wHandle; - if (handle == NULL || handle == INVALID_HANDLE_VALUE) + if (handle == NULL) return FALSE; + /* INVALID_HANDLE_VALUE is an invalid value for every handle, but it + * confuses the clang scanbuild analyzer. */ +#ifndef __clang_analyzer__ + if (handle == INVALID_HANDLE_VALUE) + return FALSE; +#endif + wHandle = (WINPR_HANDLE*) handle; *pType = wHandle->Type; -- 2.7.4