Some small fixes found by @jonathangray with cppcheck/scan-build.

This commit is contained in:
Reyk Floeter 2017-06-29 12:48:15 +02:00
parent 3109f9243a
commit 2b1181c2ca
3 changed files with 9 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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("");