summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-01-28 20:27:51 -0800
committerPeter Hutterer <peter.hutterer@who-t.net>2014-02-19 10:24:35 +1000
commit4447d71b9a74afe91aaf4cc01eae12a44ef09306 (patch)
tree3aa16ebab3fc7989a2ddb106dc4e07da49c68df0
parent2ac840a14958fe74170518ee2c3a6b2dd88b20bd (diff)
xf86DeleteScreen: move check for NULL pScrn before first dereference
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@oracle.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com> (cherry picked from commit c1ac89c793614797e08d3d8e7fc9ba55be899130)
-rw-r--r--hw/xfree86/common/xf86Helper.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index f1e6783a7..676cc8062 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)