aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui-calendar.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-07-21 22:51:54 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-07-22 11:47:14 +0200
commit21fc7a4b7422f8b441a6266a11cc8e337aae190d (patch)
treeea32977883135de411f75f82eb5089792fc3ac2d /src/ui-calendar.c
parent6203966fbf1f8886ff59cc9d6350b034ee5374c9 (diff)
downloadcalcurse-21fc7a4b7422f8b441a6266a11cc8e337aae190d.tar.gz
calcurse-21fc7a4b7422f8b441a6266a11cc8e337aae190d.zip
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 <calcurse@cryptocrack.de>
Diffstat (limited to 'src/ui-calendar.c')
-rw-r--r--src/ui-calendar.c6
1 files changed, 3 insertions, 3 deletions
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;