summaryrefslogtreecommitdiff
path: root/libspectre
diff options
context:
space:
mode:
authorRandy <randy408@protonmail.com>2020-03-02 20:58:40 +0000
committerAlbert Astals Cid <tsdgeos@yahoo.es>2020-03-02 20:58:40 +0000
commit79741b6e1b8abdcb7366d4f35d9bfa041854bfab (patch)
treeb89d3030c548738738dddb8e58970781276c2af5 /libspectre
parent836217c48d2b499f9dda2dcc848cf1dc85a4b18a (diff)
Fix memory leak
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20283
Diffstat (limited to 'libspectre')
-rw-r--r--libspectre/ps.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libspectre/ps.c b/libspectre/ps.c
index e6b508c..678aa7f 100644
--- a/libspectre/ps.c
+++ b/libspectre/ps.c
@@ -588,11 +588,12 @@ psscan(FILE *file, const char *filename, int scanstyle)
// fall-through
case 1:
if (maxpages > 0) {
+ PS_free(doc->pages);
doc->pages = (struct page *) PS_calloc(maxpages,
sizeof(struct page));
- if (!doc->pages)
- maxpages = 0;
- CHECK_MALLOCED(doc->pages);
+ if (!doc->pages)
+ maxpages = 0;
+ CHECK_MALLOCED(doc->pages);
}
}
}