diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-12-28 19:44:40 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-12-29 10:17:52 -0800 |
commit | cc9d2e808de20723c9035952242d966455d583b7 (patch) | |
tree | 2a2cc89e747b7ff963dc6cb36e6e7538692f6a3e | |
parent | 644ba5d11049e63ea61b5cc4fb889b0f840965ff (diff) |
Check MGAAllocAdaptor() for memory allocation failure
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 322 of src/mga_video.c in function 'MGASetupImageVideoTexture'.
Function 'MGAAllocAdaptor' may return constant 'NULL' at line 237, called at line 320.
Null pointer introduced at line 237 in function 'MGAAllocAdaptor'.
repeated for every line writing to the adapt pointer in each 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>
Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
-rw-r--r-- | src/mga_video.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/mga_video.c b/src/mga_video.c index 784e7b1..abce31f 100644 --- a/src/mga_video.c +++ b/src/mga_video.c @@ -269,6 +269,8 @@ MGASetupImageVideoOverlay(ScreenPtr pScreen) XF86VideoAdaptorPtr adapt; adapt = MGAAllocAdaptor(pScrn, TRUE); + if (adapt == NULL) + return NULL; adapt->type = XvWindowMask | XvInputMask | XvImageMask; adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; @@ -316,6 +318,8 @@ MGASetupImageVideoTexture(ScreenPtr pScreen) MGAPtr pMga = MGAPTR(pScrn); adapt = MGAAllocAdaptor(pScrn, FALSE); + if (adapt == NULL) + return NULL; adapt->type = XvWindowMask | XvInputMask | XvImageMask; adapt->flags = 0; @@ -1298,6 +1302,8 @@ MGASetupImageVideoILOAD(ScreenPtr pScreen) MGAPtr pMga = MGAPTR(pScrn); adapt = MGAAllocAdaptor(pScrn, FALSE); + if (adapt == NULL) + return NULL; adapt->type = XvWindowMask | XvInputMask | XvImageMask; adapt->flags = 0; |