summary refs log tree commit diff
path: root/pkgs/development/libraries/libspectre/0002-Allocate-at-least-1-page-in-doc-pages.patch
blob: 09ab9e11c16f7ae0ec938bcaeeb6817fc081024a (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
30
31
32
33
34
35
36
37
38
From 8ffd9185f81cb8337cece4c8e3672d0e6a97e935 Mon Sep 17 00:00:00 2001
From: Marek Kasik <mkasik@redhat.com>
Date: Wed, 24 Nov 2010 15:54:14 +0100
Subject: [PATCH 2/2] Allocate at least 1 page in doc->pages

Allocate at least 1 page if there are no %%Pages: or %%Page: comments
in the PS file (#31512).
---
 libspectre/ps.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libspectre/ps.c b/libspectre/ps.c
index 4578cec..0130fb4 100644
--- a/libspectre/ps.c
+++ b/libspectre/ps.c
@@ -1004,14 +1004,14 @@ psscan(const char *filename, int scanstyle)
 	section_len += line_len;
     }
 
+    if (maxpages == 0) {
+	maxpages = 1;
+	doc->pages = (struct page *) PS_calloc(maxpages, sizeof(struct page));
+	CHECK_MALLOCED(doc->pages);
+    }
 
 newpage:
     while (DSCcomment(line) && iscomment(line+2, "Page:")) {
-	if (maxpages == 0) {
-	    maxpages = 1;
-	    doc->pages = (struct page *) PS_calloc(maxpages, sizeof(struct page));
-            CHECK_MALLOCED(doc->pages);
-	}
 	label = ps_gettext(line+length("%%Page:"), &next_char);
 	if (sscanf(next_char, "%u", &thispage) != 1) thispage = 0;
 	if (nextpage == 1) {
-- 
1.7.11