From 206ec1a06b8c65ebfc48306ff69a99b92a32a062 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Wed, 26 Jul 2006 08:53:30 +0000 Subject: [PATCH] - MFH #38212, Segfault on invalid imagecreatefromgd2part() parameters --- ext/gd/libgd/gd_gd2.c | 4 ++++ ext/gd/tests/bug38212.phpt | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 ext/gd/tests/bug38212.phpt diff --git a/ext/gd/libgd/gd_gd2.c b/ext/gd/libgd/gd_gd2.c index 1e739179e2..3f24e4a476 100644 --- a/ext/gd/libgd/gd_gd2.c +++ b/ext/gd/libgd/gd_gd2.c @@ -430,6 +430,10 @@ gdImagePtr gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, gdImagePtr im; + if (w<1 || h <1) { + return 0; + } + /* The next few lines are basically copied from gd2CreateFromFile * we change the file size, so don't want to use the code directly. * but we do need to know the file size. diff --git a/ext/gd/tests/bug38212.phpt b/ext/gd/tests/bug38212.phpt new file mode 100644 index 0000000000..0094712a55 --- /dev/null +++ b/ext/gd/tests/bug38212.phpt @@ -0,0 +1,17 @@ +--TEST-- +imagecopy doen't copy alpha, palette to truecolor +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: imagecreatefromgd2part(): '%sbug38212.gd2' is not a valid GD2 file in %sbug38212.php on line %d -- 2.50.1