aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-11-06 14:05:58 +0000
committerMartin Willi <martin@strongswan.org>2008-11-06 14:05:58 +0000
commitebf0e20ae72691f9dc3863f1573e4f19e4f0d4b1 (patch)
treecfcc177329e1111c34924ae8cc9eff5129db66b2
parente76078e877f57dc7a8adf4dab06bebdcf62b9c6d (diff)
downloadstrongswan-ebf0e20ae72691f9dc3863f1573e4f19e4f0d4b1.tar.bz2
strongswan-ebf0e20ae72691f9dc3863f1573e4f19e4f0d4b1.tar.xz
fixed leak
fixed build if !HAVE_BACKTRACE
-rw-r--r--src/libstrongswan/utils/backtrace.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libstrongswan/utils/backtrace.c b/src/libstrongswan/utils/backtrace.c
index be3857248..3caafdc38 100644
--- a/src/libstrongswan/utils/backtrace.c
+++ b/src/libstrongswan/utils/backtrace.c
@@ -103,6 +103,7 @@ static void log_(private_backtrace_t *this, FILE *file)
}
fputc(c, file);
}
+ pclose(output);
}
else
{
@@ -163,12 +164,15 @@ backtrace_t *backtrace_create(int skip)
{
private_backtrace_t *this;
void *frames[50];
- int frame_count;
+ int frame_count = 0;
+#ifdef HAVE_BACKTRACE
frame_count = backtrace(frames, countof(frames));
+#endif /* HAVE_BACKTRACE */
+ frame_count = max(frame_count - skip, 0);
this = malloc(sizeof(private_backtrace_t) + frame_count * sizeof(void*));
- this->frame_count = frame_count - skip;
- memcpy(this->frames, frames + skip, this->frame_count * sizeof(void*));
+ memcpy(this->frames, frames + skip, frame_count * sizeof(void*));
+ this->frame_count = frame_count;
this->public.log = (void(*)(backtrace_t*,FILE*))log_;
this->public.contains_function = (bool(*)(backtrace_t*, char *function))contains_function;