Fixes a scan-build warning.
-- v2: msvcrt: Use 'else if' in _wgetcwd.
From: Alex Henrie alexhenrie24@gmail.com
Fixes a scan-build warning. --- dlls/msvcrt/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c index 72c8018a74b..546e8d49a7b 100644 --- a/dlls/msvcrt/dir.c +++ b/dlls/msvcrt/dir.c @@ -824,7 +824,7 @@ wchar_t* CDECL _wgetcwd(wchar_t * buf, int size) if (size <= dir_len) size = dir_len + 1; if (!(buf = malloc( size * sizeof(WCHAR) ))) return NULL; } - if (dir_len >= size) + else if (dir_len >= size) { *_errno() = ERANGE; return NULL; /* buf too small */
On Mon Jun 5 12:12:41 2023 +0000, Piotr Caban wrote:
There's no leak here. In case !buf we're updating size if it's to small. The code can be changed to:
else if (dir_len >= size)
to make it easier to read.
My apologies for not reading the code closely enough. I like your idea of using `else if` to suppress the warning, and I've pushed a new patch that does exactly that.
This merge request was approved by Piotr Caban.