summaryrefslogtreecommitdiff
path: root/debian/patches/0015-xmllint-pretty-crashed-without-following-numeric-arg.patch
blob: b910c3ae5284d07c1eaa8f4bc5b3c94b45f1b997 (plain)
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
From: Tim Galeckas <tim@galeckas.com>
Date: Thu, 29 Aug 2013 16:44:33 +0800
Subject: xmllint --pretty crashed without following numeric argument

https://bugzilla.gnome.org/show_bug.cgi?id=674789

We need to check for NULL argument before calling atoi()
---
 xmllint.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/xmllint.c b/xmllint.c
index 92e6b03..d69722c 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -3388,11 +3388,13 @@ main(int argc, char **argv) {
 	         (!strcmp(argv[i], "--pretty"))) {
 	     i++;
 #ifdef LIBXML_OUTPUT_ENABLED
-	     format = atoi(argv[i]);
-	     if (format == 1) {
-	         noblanks++;
-	         xmlKeepBlanksDefault(0);
-	     }
+       if (argv[i] != NULL) {
+	         format = atoi(argv[i]);
+	         if (format == 1) {
+	             noblanks++;
+	             xmlKeepBlanksDefault(0);
+	         }
+       }
 #endif /* LIBXML_OUTPUT_ENABLED */
 	}
 #ifdef LIBXML_READER_ENABLED