commit 49a4637c6c7300a0ea4ab415bb5ac7f2af47ee86
parent c690f56af6eb4029ba438b9efdb7e31f250c539c
Author: tongong <tongong@gmx.net>
Date: Sat, 12 Jun 2021 21:45:22 +0200
fixed segfault
didn't set pointer to NULL between free() and realloc()
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/timetracker-save.c b/timetracker-save.c
@@ -94,7 +94,7 @@ time_t addprogram(_Bool forcewrite) {
if (writetime <= newtime || forcewrite) {
/* write to data file */
- char * loc = filelocation();
+ char *loc = filelocation();
FILE *dataFile = fopen(loc, "a");;
free(loc);
@@ -107,6 +107,7 @@ time_t addprogram(_Bool forcewrite) {
/* reset everything */
free(programs);
+ programs = NULL;
programnum = 0;
writetime = newtime + WRITE_INTERVAL;
}