- Double free
- Use-after-free
/* Now we can reallocate the buffer. */
p = (char *)realloc(as->s, new_length);
if (p == NULL) {
+ /* Prevent the duble free of as->s in archive_string_free
+ * since realloc function already freed the memory. */
+ as->s = NULL;
/* On failure, wipe the string and return NULL. */
archive_string_free(as);
errno = ENOMEM;/* Make sure errno has ENOMEM. */
}
sc->to_charset = strdup(tc);
if (sc->to_charset == NULL) {
- free(sc);
free(sc->from_charset);
+ free(sc);
return (NULL);
}
archive_string_init(&sc->utftmp);