[PATCH resend 3/4] xf86DeleteScreen: move check for NULL pScrn before first dereference
Alan Coopersmith
alan.coopersmith at oracle.com
Tue Jan 28 20:27:51 PST 2014
Flagged by cppcheck 1.62:
[hw/xfree86/common/xf86Helper.c:220] -> [hw/xfree86/common/xf86Helper.c:231]:
(warning) Possible null pointer dereference: pScrn - otherwise it is
redundant to check it against null.
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
hw/xfree86/common/xf86Helper.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 2c0629d..12a8771 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -217,6 +217,10 @@ xf86DeleteScreen(ScrnInfoPtr pScrn)
int i;
int scrnIndex;
Bool is_gpu = FALSE;
+
+ if (!pScrn)
+ return;
+
if (pScrn->is_gpu) {
/* First check if the screen is valid */
if (xf86NumGPUScreens == 0 || xf86GPUScreens == NULL)
@@ -228,9 +232,6 @@ xf86DeleteScreen(ScrnInfoPtr pScrn)
return;
}
- if (!pScrn)
- return;
-
scrnIndex = pScrn->scrnIndex;
/* If a FreeScreen function is defined, call it here */
if (pScrn->FreeScreen != NULL)
--
1.7.9.2
More information about the xorg-devel
mailing list