summaryrefslogtreecommitdiff
path: root/libspectre
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2010-10-30 15:55:18 +0200
committerCarlos Garcia Campos <carlosgc@gnome.org>2010-10-30 16:00:13 +0200
commit7500e4d1ae85ecf9f61b1446e07ebb887118757c (patch)
treea0e88120c336f667b52a7b7c9d2fb9c596c8ed60 /libspectre
parent213dfcef5ee9e44f0f9e9026222beb0e69a4257d (diff)
Fix a crash with documents containing an invalid %%Pages: comment
When failed to allocate memory for pages because of invalid %%Pages: comment, set maxpages to 0 to ignore the comment. Problem spotted by Marek Kasik. Fixes bug #30867.
Diffstat (limited to 'libspectre')
-rw-r--r--libspectre/ps.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libspectre/ps.c b/libspectre/ps.c
index 6c7cfce..4578cec 100644
--- a/libspectre/ps.c
+++ b/libspectre/ps.c
@@ -597,6 +597,8 @@ psscan(const char *filename, int scanstyle)
if (maxpages > 0) {
doc->pages = (struct page *) PS_calloc(maxpages,
sizeof(struct page));
+ if (!doc->pages)
+ maxpages = 0;
CHECK_MALLOCED(doc->pages);
}
}