diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-11 14:49:17 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-11 14:49:17 -0800 |
commit | 993abe751f4141f54d8d28b8b73588a1c9085970 (patch) | |
tree | c3ce5d6cb684c95f7d4b50b36c5da3d243699caf | |
parent | 6ac417cea1136a3617f5e40f4b106aaa3f48d6c2 (diff) |
Clean up memory when first XCreateRegion succeeds and second fails
Error: Memory leak (CWE 401)
Memory leak of pointer 's' allocated with XCreateRegion()
at line 387 of /export/alanc/X.Org/sx86-gcc/lib/libX11/src/Region.c in function 'XShrinkRegion'.
's' allocated at line 387 with XCreateRegion().
s leaks when s != 0 at line 387.
Error: Memory leak (CWE 401)
Memory leak of pointer 'tra' allocated with XCreateRegion()
at line 1452 of /export/alanc/X.Org/sx86-gcc/lib/libX11/src/Region.c in function 'XXorRegion'.
'tra' allocated at line 1451 with XCreateRegion().
tra leaks when tra != 0 at line 1451.
[ This bug was found by the Parfait 0.3.6 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/Region.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Region.c b/src/Region.c index 45a0bda..41047b2 100644 --- a/src/Region.c +++ b/src/Region.c @@ -384,7 +384,12 @@ XShrinkRegion( int grow; if (!dx && !dy) return 0; - if ((! (s = XCreateRegion())) || (! (t = XCreateRegion()))) return 0; + if (! (s = XCreateRegion()) ) + return 0; + if (! (t = XCreateRegion()) ) { + XDestroyRegion(s); + return 0; + } if ((grow = (dx < 0))) dx = -dx; if (dx) Compress(r, s, t, (unsigned) 2*dx, TRUE, grow); if ((grow = (dy < 0))) dy = -dy; @@ -1448,8 +1453,12 @@ XXorRegion(Region sra, Region srb, Region dr) { Region tra, trb; - if ((! (tra = XCreateRegion())) || (! (trb = XCreateRegion()))) + if (! (tra = XCreateRegion()) ) return 0; + if (! (trb = XCreateRegion()) ) { + XDestroyRegion(tra); + return 0; + } (void) XSubtractRegion(sra,srb,tra); (void) XSubtractRegion(srb,sra,trb); (void) XUnionRegion(tra,trb,dr); |