about summary refs log tree commit diff
path: root/pkgs/development/libraries/libspectre/0001-Fix-a-crash-with-documents-containing-an-invalid-Pag.patch
blob: 3e232ee5ac500c10493ce1c3f63029a45713569a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From 7500e4d1ae85ecf9f61b1446e07ebb887118757c Mon Sep 17 00:00:00 2001
From: Carlos Garcia Campos <carlosgc@gnome.org>
Date: Sat, 30 Oct 2010 15:55:18 +0200
Subject: [PATCH 1/2] 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.
---
 libspectre/ps.c | 2 ++
 1 file changed, 2 insertions(+)

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