diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-12-29 18:15:57 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-12-29 18:37:42 -0800 |
commit | 8df1a843a3a9f92399113688a350873a141bf995 (patch) | |
tree | c017568a201ded28868d25558403d6cb0ffee8fe | |
parent | a0db0f6c7996b282aa9027d3b670597d88fe3353 (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>
-rw-r--r-- | Bitmap.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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 { |