summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-04-19 20:12:30 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-04-19 20:12:50 -0700
commitffcae9381f914871cc51c80112ce39e83dc8d04b (patch)
tree35757fd6d09a281e34277dee77189f57c1e5a323
parent68e02860d9ee6d65733457e689d180653fc9829f (diff)
Avoid leaking pixel memory if DUMMYScreenInit fails
Resolves issues reported by Oracle Parfait static analyzer: Error: Memory leak Memory leak [memory-leak] (CWE 401): Memory leak of pointer pixels allocated with malloc((pScrn->videoRam * 1024)) at line 803 of dummy_driver.c in function 'DUMMYScreenInit'. pixels allocated at line 790 with malloc((pScrn->videoRam * 1024)) Memory leak [memory-leak] (CWE 401): Memory leak of pointer pixels allocated with malloc((pScrn->videoRam * 1024)) at line 805 of dummy_driver.c in function 'DUMMYScreenInit'. pixels allocated at line 790 with malloc((pScrn->videoRam * 1024)) Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/dummy_driver.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/dummy_driver.c b/src/dummy_driver.c
index 2d1ecfd..5f56d9d 100644
--- a/src/dummy_driver.c
+++ b/src/dummy_driver.c
@@ -798,11 +798,16 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
/* Setup the visuals we support. */
if (!miSetVisualTypes(pScrn->depth,
- miGetDefaultVisualMask(pScrn->depth),
- pScrn->rgbBits, pScrn->defaultVisual))
- return FALSE;
+ miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual)) {
+ free(pixels);
+ return FALSE;
+ }
- if (!miSetPixmapDepths ()) return FALSE;
+ if (!miSetPixmapDepths ()) {
+ free(pixels);
+ return FALSE;
+ }
/*
* Call the framebuffer layer's ScreenInit function, and fill in other