summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2017-01-19 01:02:58 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2017-01-19 01:02:58 +0100
commit55ac28a293eaa8c531870c8bb8ecc04b333975f4 (patch)
tree221ff056c156d844d645bea6f36b5d9a565f31aa
parent7e3587af06c7f89cb749442a689638241b486afb (diff)
downloadlibgd-55ac28a293eaa8c531870c8bb8ecc04b333975f4.tar.gz
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.
-rw-r--r--src/gd_io_dp.c4
1 files changed, 4 insertions, 0 deletions
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;