aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-11-15 19:27:57 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-12-06 09:30:37 -0800
commitd48a67725980629aa99b2ebdac734a0f0118e5ab (patch)
treee70b50b50a64efc8ff17088432875a1895443318
parent8daf6128f61fd52516c14e1bb2a64b4047f1daf4 (diff)
downloadsubsurface-d48a67725980629aa99b2ebdac734a0f0118e5ab.tar.gz
planner.c: fix 'disclaimer' pointing to stack memory
In add_plan_to_notes() the 'disclaimer' is set to the temporary buffer 'buf'. By making 'buf' static, 'disclaimer' now points to a persistent buffer. Bug was reported as bad characters when printing the planner deco text. Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--planner.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/planner.c b/planner.c
index 22d37165a..9c8b9e952 100644
--- a/planner.c
+++ b/planner.c
@@ -534,7 +534,8 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
const unsigned int sz_temp = 100000;
char *buffer = (char *)malloc(sz_buffer);
char *temp = (char *)malloc(sz_temp);
- char buf[1000], *deco;
+ char *deco;
+ static char buf[1000];
int len, lastdepth = 0, lasttime = 0, lastsetpoint = -1, newdepth = 0, lastprintdepth = 0, lastprintsetpoint = -1;
struct gasmix lastprintgasmix = {{ -1 }, { -1 }};
struct divedatapoint *dp = diveplan->dp;