summaryrefslogtreecommitdiff
path: root/Bitmap.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-12-29 18:15:57 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-12-29 18:37:42 -0800
commit8df1a843a3a9f92399113688a350873a141bf995 (patch)
treec017568a201ded28868d25558403d6cb0ffee8fe /Bitmap.c
parenta0db0f6c7996b282aa9027d3b670597d88fe3353 (diff)
Stop memory leaks from XtNewString(StripFilename(filename))
StripFilename() already allocates a new string for its result, we don't need to duplicate it and then lose the pointer to the first one. Fixes errors found by Oracle Parfait 1.5.1 bug checking tool: Error: Memory leak (CWE 401) Memory leak of pointer pointer allocated with StripFilename(filename) at line 1119 of Bitmap.c in function 'BWReadFile'. pointer allocated at line 1106 with StripFilename(filename). pointer leaks when StripFilename(filename) != NULL at line 1106. Error: Memory leak (CWE 401) Memory leak of pointer pointer allocated with StripFilename(filename) at line 1119 of Bitmap.c in function 'BWReadFile'. pointer allocated at line 1106 with StripFilename(filename). Error: Memory leak (CWE 401) Memory leak of pointer pointer allocated with StripFilename(filename) at line 1222 of Bitmap.c in function 'BWWriteFile'. pointer allocated at line 1202 with StripFilename(filename). pointer leaks when StripFilename(filename) != NULL at line 1202. Error: Memory leak (CWE 401) Memory leak of pointer pointer allocated with StripFilename(filename) at line 1222 of Bitmap.c in function 'BWWriteFile'. pointer allocated at line 1202 with StripFilename(filename). Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'Bitmap.c')
-rw-r--r--Bitmap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Bitmap.c b/Bitmap.c
index 76464f9..2a8e46d 100644
--- a/Bitmap.c
+++ b/Bitmap.c
@@ -1103,7 +1103,7 @@ BWReadFile(Widget w, _Xconst _XtString filename, _Xconst _XtString basename) /*
XtFree(BW->bitmap.filename);
BW->bitmap.filename = XtNewString(filename);
XtFree(BW->bitmap.basename);
- BW->bitmap.basename= XtNewString(StripFilename(filename));
+ BW->bitmap.basename = StripFilename(filename);
BWUnmark(w);
@@ -1199,7 +1199,7 @@ BWWriteFile(Widget w, _Xconst _XtString filename, _Xconst _XtString basename)
XtFree(BW->bitmap.filename);
BW->bitmap.filename = XtNewString(filename);
XtFree(BW->bitmap.basename);
- BW->bitmap.basename= XtNewString(StripFilename(filename));
+ BW->bitmap.basename = StripFilename(filename);
}
if (!basename) basename = BW->bitmap.basename;
else {