Browse Source

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

fix-cms
Reyk Floeter 6 years ago
parent
commit
2b1181c2ca
  1. 3
      agent/azure.c
  2. 5
      agent/main.c
  3. 4
      agent/xml.c

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

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

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

Loading…
Cancel
Save