summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2008-02-10 16:29:50 +0000
committerFrederic Culot <calcurse@culot.org>2008-02-10 16:29:50 +0000
commit52340fa0e132766e9a0d1e5a95d45282725cdf97 (patch)
treea54b7b3410ba13453c87f0a1efeb7923839c740d /src
parent886466310798ee9d63191cff05d57c4e9528b32e (diff)
downloadcalcurse-52340fa0e132766e9a0d1e5a95d45282725cdf97.tar.gz
calcurse-52340fa0e132766e9a0d1e5a95d45282725cdf97.zip
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
Diffstat (limited to 'src')
-rwxr-xr-xsrc/notify.c5
-rwxr-xr-xsrc/utils.c3
-rwxr-xr-xsrc/wins.c13
3 files changed, 15 insertions, 6 deletions
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(&notify_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 <time.h>
#include <string.h>
#include <stdlib.h>
+#include <limits.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/types.h>
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 <stdlib.h>
+#include <string.h>
#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();