summaryrefslogtreecommitdiff
path: root/debian/patches/0040-Avoid-Possible-Null-Pointer-in-trio.c.patch
blob: 22895c1b95c8c9a1b92553b6d5468584a759f966 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
From: Gaurav Gupta <g.gupta@samsung.com>
Date: Mon, 14 Jul 2014 21:22:07 +0800
Subject: Avoid Possible Null Pointer in trio.c

For https://bugzilla.gnome.org/show_bug.cgi?id=730005
While using assert in libxml2 is really not a good idea, it's
still better to assert than crash
---
 trio.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/trio.c b/trio.c
index d885db9..1bf99e3 100644
--- a/trio.c
+++ b/trio.c
@@ -6418,11 +6418,14 @@ TRIO_ARGS2((self, intPointer),
 	   trio_class_t *self,
 	   int *intPointer)
 {
-  FILE *file = (FILE *)self->location;
+  FILE *file;
 
   assert(VALID(self));
+  assert(VALID(self->location));
   assert(VALID(file));
 
+  file = (FILE *)self->location;
+
   self->current = fgetc(file);
   if (self->current == EOF)
     {
@@ -6451,11 +6454,14 @@ TRIO_ARGS2((self, intPointer),
 	   trio_class_t *self,
 	   int *intPointer)
 {
-  int fd = *((int *)self->location);
+  int fd;
   int size;
   unsigned char input;
 
   assert(VALID(self));
+  assert(VALID(self->location));
+
+  fd = *((int *)self->location);
 
   size = read(fd, &input, sizeof(char));
   if (size == -1)