Message ID | 1383121090-18727-1-git-send-email-liwang@ubuntukylin.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
diff --git a/src/common/BackTrace.cc b/src/common/BackTrace.cc index 6cace65..886ed6a 100644 --- a/src/common/BackTrace.cc +++ b/src/common/BackTrace.cc @@ -36,8 +36,10 @@ void BackTrace::print(std::ostream& out) if (begin && end) { int len = end - begin; char *foo = (char *)malloc(len+1); - if (!foo) - return; + if (!foo) { + free(function); + return; + } memcpy(foo, begin, len); foo[len] = 0;
Free already allocated memory if short of memory Signed-off-by: Li Wang <liwang@ubuntukylin.com> --- src/common/BackTrace.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)