diff --git a/agent/azure.c b/agent/azure.c index 4fd6623..ace0460 100644 --- a/agent/azure.c +++ b/agent/azure.c @@ -483,7 +483,7 @@ azure_getpubkeys(struct system_config *sc) FILE *fp; int ret = -1; FILE *infp = NULL; - char *inbuf; + char *inbuf = NULL; size_t inbufsz; if ((fp = fopen(az->az_certs, "r")) == NULL) { @@ -769,6 +769,7 @@ azure_getendpoint(struct system_config *sc) if (asprintf(&ep, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]) == -1) { log_debug("%s: asprintf", __func__); + fclose(fp); return (-1); } } diff --git a/agent/main.c b/agent/main.c index 0887c2b..e235e4e 100644 --- a/agent/main.c +++ b/agent/main.c @@ -162,6 +162,7 @@ shellout(const char *in, char **out, const char *arg, ...) } free(argv); + argv = NULL; sigaction(SIGINT, NULL, &sigint); sigaction(SIGQUIT, NULL, &sigquit); @@ -381,8 +382,10 @@ filein(const char *mode, const char *fmt, ...) return (NULL); } free(path); - if ((infp = open_memstream(&inbuf, &inbufsz)) == NULL) + if ((infp = open_memstream(&inbuf, &inbufsz)) == NULL) { fclose(fp); + return (NULL); + } while (fgets(buf, sizeof(buf), fp) != NULL) { fputs(buf, infp); } diff --git a/agent/xml.c b/agent/xml.c index 6440f4c..a67bfa4 100644 --- a/agent/xml.c +++ b/agent/xml.c @@ -235,7 +235,9 @@ xml_end_element(void *data, const char *el) struct xml *env = data; struct xmlelem *xe = env->ox_cur; - if (xe == NULL || strcmp(xe->xe_tag, el) != 0) + if (xe == NULL) + fatal("missing element"); + if (strcmp(xe->xe_tag, el) != 0) fatal("unexpected closing tag: %s <> %s", el, xe->xe_tag); if (xe->xe_data == NULL) xe->xe_data = strdup("");