diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-05-26 14:44:26 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-05-28 10:03:01 -0700 |
commit | ca35cff72a3100c9367b7e7f4811117c8733b8be (patch) | |
tree | ffd464f7f05a9ca54bfd22b2ac96dfd0b08c2341 | |
parent | 11c3a104141e1a4946ad949dfb5514df0b66a031 (diff) | |
download | xorg-lib-libXaw-ca35cff72a3100c9367b7e7f4811117c8733b8be.tar.gz |
Correct order of arguments to XawStackFree()
XawStackAlloc() & XawStackFree() are macros to automate the process of
using a fixed size stack buffer for strings smaller than the buffer size,
and allocating/freeing memory for larger strings.
XawStackFree is defined in src/Private.h as taking (pointer, stk_buffer)
and freeing pointer if it's not pointing to the stack buffer.
Most of the calls of this macro get the ordering right, but a couple
got it reversed, passing a stack buffer to free() instead of the
allocated pointer.
Found by the Parfait 0.5.0.1 bug checking tool:
Error: Free memory not allocated dynamically by alloc (CWE 590)
Free() was called on a pointer 'buf' to the auto variable 'buf'. Free() must only be used on dynamically allocated memory
at line 2281 of TextAction.c in function 'DoFormatText'.
'buf' allocated at line 0 as auto variable.
at line 2296 of TextAction.c in function 'DoFormatText'.
'buf' allocated at line 0 as auto variable.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Acked-by: pcpa <paulo.cesar.pereira.de.andrade@gmail.com>
-rw-r--r-- | src/TextAction.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/TextAction.c b/src/TextAction.c index 6705316..fe7e573 100644 --- a/src/TextAction.c +++ b/src/TextAction.c @@ -2278,7 +2278,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, text.length = bytes; bytes -= text.length; if (_XawTextReplace(ctx, tmp, tmp, &text)) { - XawStackFree(buf, text.ptr); + XawStackFree(text.ptr, buf); return (XawEditError); } if (num_pos) { @@ -2293,7 +2293,7 @@ DoFormatText(TextWidget ctx, XawTextPosition left, Bool force, int level, } position += count; right += count; - XawStackFree(buf, text.ptr); + XawStackFree(text.ptr, buf); } break; } |