diff --git a/code/autoupdater/autoupdater.c b/code/autoupdater/autoupdater.c index 7e20d331..f2e05357 100644 --- a/code/autoupdater/autoupdater.c +++ b/code/autoupdater/autoupdater.c @@ -76,7 +76,7 @@ typedef struct ManifestItem struct ManifestItem *next; } ManifestItem; -static ManifestItem *manifest; +static ManifestItem *manifest = NULL; static void freeManifest(void) { @@ -92,6 +92,22 @@ static void freeManifest(void) manifest = NULL; } +static const char *timestamp(void) +{ + time_t t = time(NULL); + char *retval = asctime(localtime(&t)); + if (retval) { + char *ptr; + for (ptr = retval; *ptr; ptr++) { + if ((*ptr == '\r') || (*ptr == '\n')) { + *ptr = '\0'; + break; + } + } + } + return retval ? retval : "[date unknown]"; +} + static FILE *logfile = NULL; @@ -140,8 +156,10 @@ static void die(const char *why) NEVER_RETURNS; static void die(const char *why) { infof("FAILURE: %s", why); + curl_global_cleanup(); restoreRollbacks(); freeManifest(); + infof("Updater ending (in failure), %s", timestamp()); exit(1); } @@ -628,22 +646,6 @@ static void deleteRollbacks(void) } } -static const char *timestamp(void) -{ - time_t t = time(NULL); - char *retval = asctime(localtime(&t)); - if (retval) { - char *ptr; - for (ptr = retval; *ptr; ptr++) { - if ((*ptr == '\r') || (*ptr == '\n')) { - *ptr = '\0'; - break; - } - } - } - return retval ? retval : "[date unknown]"; -} - static void chdirToBasePath(const char *argv0) { const char *fname = justFilename(argv0);