From d66942a5521aa935f1c3a8e128b69270734a9684 Mon Sep 17 00:00:00 2001 From: Johan Date: Tue, 21 Oct 2025 09:48:25 +0200 Subject: [PATCH] Potential fix for code scanning alert no. 1: Redundant null check due to previous dereference This rule finds comparisons of a pointer to null that occur after a reference of that pointer. It's likely either the check is not required and can be removed, or it should be moved to before the dereference so that a null pointer dereference does not occur. Recommendation The check should be moved to before the dereference, in a way that prevents a null pointer value from being dereferenced. If it's clear that the pointer cannot be null, consider removing the check instead. References Null Dereference https://owasp.org/www-community/vulnerabilities/Null_Dereference Common Weakness Enumeration: CWE-476. https://cwe.mitre.org/data/definitions/476.html Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- UI/BaseDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/BaseDialog.cpp b/UI/BaseDialog.cpp index 390abec1..ae3d9bd7 100644 --- a/UI/BaseDialog.cpp +++ b/UI/BaseDialog.cpp @@ -306,7 +306,7 @@ void UIElement::MeasureTextVSize(const char* text, int* width, int* height, HWND assert(wnd); // get control's width - int w = *width; + int w = width ? *width : -1; if (w < 0) { //!! see AllocateUISpace() for details, should separate common code in some way