Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Sep 2017 11:16:33 +0000 (UTC)
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324013 - head/usr.bin/calendar
Message-ID:  <201709261116.v8QBGX0W006416@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bapt
Date: Tue Sep 26 11:16:33 2017
New Revision: 324013
URL: https://svnweb.freebsd.org/changeset/base/324013

Log:
  calendar: replace strcpy/strcat with asprintf

Modified:
  head/usr.bin/calendar/events.c

Modified: head/usr.bin/calendar/events.c
==============================================================================
--- head/usr.bin/calendar/events.c	Tue Sep 26 11:11:17 2017	(r324012)
+++ head/usr.bin/calendar/events.c	Tue Sep 26 11:16:33 2017	(r324013)
@@ -86,12 +86,9 @@ event_continue(struct event *e, char *txt)
 		errx(1, "event_continue: cannot allocate memory");
 
 	free(e->text);
-	e->text = (char *)malloc(strlen(text) + strlen(txt) + 3);
+	asprintf(&e->text, "%s\n%s", text, txt);
 	if (e->text == NULL)
 		errx(1, "event_continue: cannot allocate memory");
-	strcpy(e->text, text);
-	strcat(e->text, "\n");
-	strcat(e->text, txt);
 	free(text);
 
 	return;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709261116.v8QBGX0W006416>