From 21fc7a4b7422f8b441a6266a11cc8e337aae190d Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 21 Jul 2014 22:51:54 +0200 Subject: Replace several uses of snprintf() by asprintf() Use asprintf() in some cold code paths. While allocating memory on the heap is a bit slower, using asprintf() is a bit more memory efficient and less prone to buffer overflow errors. Signed-off-by: Lukas Fleischer --- src/ui-calendar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui-calendar.c') diff --git a/src/ui-calendar.c b/src/ui-calendar.c index b24d555..bd8d7fe 100644 --- a/src/ui-calendar.c +++ b/src/ui-calendar.c @@ -629,7 +629,7 @@ void ui_calendar_change_day(int datefmt) { #define LDAY 11 char selected_day[LDAY] = ""; - char outstr[BUFSIZ]; + char *outstr; int dday, dmonth, dyear; int wrong_day = 1; const char *mesg_line1 = @@ -640,9 +640,9 @@ void ui_calendar_change_day(int datefmt) _("Enter the day to go to [ENTER for today] : %s"); while (wrong_day) { - snprintf(outstr, BUFSIZ, request_date, - DATEFMT_DESC(datefmt)); + asprintf(&outstr, request_date, DATEFMT_DESC(datefmt)); status_mesg(outstr, ""); + mem_free(outstr); if (getstring(win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC) { return; -- cgit v1.2.3-54-g00ecf