From 52340fa0e132766e9a0d1e5a95d45282725cdf97 Mon Sep 17 00:00:00 2001
From: Frederic Culot <calcurse@culot.org>
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

---
 src/notify.c |  5 ++++-
 src/utils.c  |  3 ++-
 src/wins.c   | 13 +++++++++----
 3 files changed, 15 insertions(+), 6 deletions(-)

(limited to 'src')

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();
-- 
cgit v1.2.3-70-g09d2