diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2018-06-01 07:29:34 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2018-08-25 10:15:33 +0200 |
commit | b6cdc292552acb1864c7cf4e46775f398d88eae3 (patch) | |
tree | cef3f1f39eabee359736b55fef72ee14720e6c2d /src | |
parent | fa353e5eb79a352ae5f5fe199f16c75b30ce3563 (diff) | |
download | calcurse-b6cdc292552acb1864c7cf4e46775f398d88eae3.tar.gz calcurse-b6cdc292552acb1864c7cf4e46775f398d88eae3.zip |
Fix seg fault in update_rept()
Memory pointers must be initialized at the start in case memory is
freed (cleanup) before it is allocated.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/ui-day.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ui-day.c b/src/ui-day.c index 1457203..af2258e 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -215,6 +215,13 @@ static void update_desc(char **desc) static void update_rept(struct rpt **rpt, const long start) { + /* Pointers to dynamically allocated memory. */ + char *msg_rpt_current = NULL; + char *msg_rpt_asktype = NULL; + char *freqstr = NULL; + char *timstr = NULL; + char *outstr = NULL; + /* Update repetition type. */ int newtype; const char *msg_rpt_prefix = _("Enter the new repetition type:"); @@ -225,7 +232,6 @@ static void update_rept(struct rpt **rpt, const long start) /* Find the current repetition type. */ const char *rpt_current; - char *msg_rpt_current; switch (recur_def2char((*rpt)->type)) { case 'D': rpt_current = msg_rpt_daily; @@ -244,7 +250,6 @@ static void update_rept(struct rpt **rpt, const long start) rpt_current = msg_rpt_daily; } asprintf(&msg_rpt_current, _("(currently using %s)"), rpt_current); - char *msg_rpt_asktype; asprintf(&msg_rpt_asktype, "%s %s, %s, %s, %s? %s", msg_rpt_prefix, msg_rpt_daily, msg_rpt_weekly, msg_rpt_monthly, msg_rpt_yearly, msg_rpt_current); @@ -268,7 +273,6 @@ static void update_rept(struct rpt **rpt, const long start) /* Update frequency. */ int newfreq; - char *freqstr = NULL; const char *msg_wrong_freq = _("Invalid frequency."); const char *msg_enter = _("Press [Enter] to continue"); do { @@ -288,8 +292,6 @@ static void update_rept(struct rpt **rpt, const long start) while (newfreq == 0); /* Update end date. */ - char *timstr = NULL; - char *outstr = NULL; time_t newuntil; const char *msg_until_1 = _("Enter end date or duration ('?' for input formats):"); |