summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-12-28 20:04:22 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-12-28 20:07:31 -0800
commitfb368727b9251b23f937a6432946dd376a153e27 (patch)
treef08d89de95c0f1a2c40c0c7178ecb1ee37f96506
parente5c1c27b83e93d9cb2a74c7c4ee85b36eb1bbdef (diff)
If it couldn't allocate memory, don't attempt to write a bunch of values
to the NULL pointer before returning it, but just pass the NULL along right away. Resolves parfait warnings of the form: Error: Null pointer dereference (CWE 476) Write to null pointer 'adapt' at line 248 of driver/xf86-video-s3/src/s3_video.c in function 'S3SetupImageVideoOverlay'. Function 'S3AllocAdaptor' may return constant 'NULL' at line 218, called at line 246. Null pointer introduced at line 218 in function 'S3AllocAdaptor'. repeated for every line writing to the adapt pointer in the function. [ This bug was found by the Parfait 0.4.2 bug checking tool. For more information see http://labs.oracle.com/projects/parfait/ ] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/s3_video.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/s3_video.c b/src/s3_video.c
index 3e88889..9a2d458 100644
--- a/src/s3_video.c
+++ b/src/s3_video.c
@@ -244,6 +244,8 @@ static XF86VideoAdaptorPtr S3SetupImageVideoOverlay(ScreenPtr pScreen)
XF86VideoAdaptorPtr adapt;
adapt = S3AllocAdaptor(pScrn);
+ if (adapt == NULL)
+ return NULL;
adapt->type = XvWindowMask | XvInputMask | XvImageMask;
adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;