summaryrefslogtreecommitdiffstats
path: root/gd-upstream.patch
blob: 8aee1a067a51b60bdc34f28ae1342873150f0d67 (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
48
49
50
From c9b601a658a79e6ea2aad29fbf60ca6e24ccef1e Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Wed, 18 Jan 2017 13:59:02 +0100
Subject: [PATCH] Fix build issue regarding INT_MAX

For portability gd_gd2.c needs to include <limits.h>.
---
 src/gd_gd2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gd_gd2.c b/src/gd_gd2.c
index c2904ca..049c4c5 100644
--- a/src/gd_gd2.c
+++ b/src/gd_gd2.c
@@ -74,6 +74,7 @@
 
 /* 2.0.29: no more errno.h, makes windows happy */
 #include <math.h>
+#include <limits.h>
 #include <string.h>
 #include "gd.h"
 #include "gd_errors.h"


From 55ac28a293eaa8c531870c8bb8ecc04b333975f4 Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Thu, 19 Jan 2017 01:02:58 +0100
Subject: [PATCH] Fix #357: 2.2.4: Segfault in test suite.

We make sure to never pass a negative `int` as argument to a `size_t`
parameter.
---
 src/gd_io_dp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/gd_io_dp.c b/src/gd_io_dp.c
index eda2eeb..cb38794 100644
--- a/src/gd_io_dp.c
+++ b/src/gd_io_dp.c
@@ -292,6 +292,10 @@ static int dynamicGetbuf(gdIOCtxPtr ctx, void *buf, int len)
 		rlen = dp->realSize - dp->pos;
 	}
 
+	if (rlen < 0) {
+		return 0;
+	}
+
 	memcpy(buf, (void *) ((char *)dp->data + dp->pos), rlen);
 	dp->pos += rlen;