From 52340fa0e132766e9a0d1e5a95d45282725cdf97 Mon Sep 17 00:00:00 2001 From: Frederic Culot Date: Sun, 10 Feb 2008 16:29:50 +0000 Subject: memory leak fixed in notify_thread_app() check for limits.h header added asprintf() call replaced in wins_launch_external() as it is not fully portable --- ChangeLog | 4 ++++ configure.ac | 4 ++-- src/notify.c | 5 ++++- src/utils.c | 3 ++- src/wins.c | 13 +++++++++---- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07cf434..37f0ef4 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 10 Feb 2008: manuals updated to make use of css style sheet + memory leak fixed in notify_thread_app() + check for limits.h header added + asprintf() call replaced in wins_launch_external() as it is not + fully portable 03 Feb 2008: doc/manual.css added diff --git a/configure.ac b/configure.ac index 97f3552..e65edad 100755 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# $calcurse: configure.ac,v 1.14 2008/01/26 10:02:01 culot Exp $ +# $calcurse: configure.ac,v 1.15 2008/02/10 16:29:50 culot Exp $ #------------------------------------------------------------------------------- # Init @@ -23,7 +23,7 @@ AC_PROG_CC AC_HEADER_STDC AC_CHECK_HEADERS([ctype.h getopt.h locale.h math.h signal.h stdbool.h stdio.h \ stdlib.h string.h sys/stat.h sys/types.h sys/wait.h time.h \ - unistd.h errno.h]) + unistd.h errno.h limits.h]) #------------------------------------------------------------------------------- # Checks for system libs #------------------------------------------------------------------------------- diff --git a/src/notify.c b/src/notify.c index 3531a02..0befe8b 100755 --- a/src/notify.c +++ b/src/notify.c @@ -1,4 +1,4 @@ -/* $calcurse: notify.c,v 1.23 2007/12/30 16:27:59 culot Exp $ */ +/* $calcurse: notify.c,v 1.24 2008/02/10 16:29:50 culot Exp $ */ /* * Calcurse - text-based organizer @@ -278,6 +278,7 @@ notify_thread_app(void *arg) tmp_app = (struct notify_app_s *) malloc(sizeof(struct notify_app_s)); tmp_app->time = current_time + DAYINSEC; tmp_app->got_app = 0; + tmp_app->txt = NULL; tmp_app = recur_apoint_check_next(tmp_app, current_time, get_today()); tmp_app = apoint_check_next(tmp_app, current_time); @@ -292,6 +293,8 @@ notify_thread_app(void *arg) } pthread_mutex_unlock(¬ify_app->mutex); + if (tmp_app->txt != NULL) + free(tmp_app->txt); free(tmp_app); notify_update_bar(); diff --git a/src/utils.c b/src/utils.c index bad5d88..6cdc246 100755 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,4 @@ -/* $calcurse: utils.c,v 1.41 2008/01/20 10:45:39 culot Exp $ */ +/* $calcurse: utils.c,v 1.42 2008/02/10 16:29:50 culot Exp $ */ /* * Calcurse - text-based organizer @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/src/wins.c b/src/wins.c index fe79588..302bb04 100755 --- a/src/wins.c +++ b/src/wins.c @@ -1,4 +1,4 @@ -/* $Id: wins.c,v 1.9 2007/12/30 16:27:59 culot Exp $ */ +/* $Id: wins.c,v 1.10 2008/02/10 16:29:50 culot Exp $ */ /* * Calcurse - text-based organizer @@ -25,6 +25,7 @@ */ #include +#include #include "i18n.h" #include "notify.h" @@ -371,10 +372,14 @@ void wins_launch_external(const char *file, const char *cmd) { char *p; - - if (asprintf(&p, "%s %s", cmd, file) == -1) - return; + int len; + len = strlen(file) + strlen(cmd) + 1; + p = (char *)malloc(sizeof(char) * len); + if (snprintf(p, len, "%s %s", cmd, file) == -1) { + free(p); + return; + } if (notify_bar()) notify_stop_main_thread(); def_prog_mode(); -- cgit v1.2.3