diff options
author | Fábio Cabral Pacheco <fcabralpacheco@gmail.com> | 2019-12-20 12:03:33 -0300 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-12-20 17:19:54 +0100 |
commit | a93eac0e843148dc2d631c3ba80af17e9c8c860f (patch) | |
tree | 54076f5e402c659d12eaea9ba4b3616ad098392c /tests | |
parent | 2e886046f86d0d6bfc14aab94a881259a081e3f4 (diff) | |
download | libgd-a93eac0e843148dc2d631c3ba80af17e9c8c860f.tar.gz |
Fix potential NULL pointer dereference in gdImageClone()
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gdimageclone/.gitignore | 1 | ||||
-rw-r--r-- | tests/gdimageclone/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/gdimageclone/Makemodule.am | 3 | ||||
-rw-r--r-- | tests/gdimageclone/style.c | 30 |
4 files changed, 34 insertions, 1 deletions
diff --git a/tests/gdimageclone/.gitignore b/tests/gdimageclone/.gitignore index a70782d..f4129cc 100644 --- a/tests/gdimageclone/.gitignore +++ b/tests/gdimageclone/.gitignore @@ -1 +1,2 @@ /bug00300 +/style diff --git a/tests/gdimageclone/CMakeLists.txt b/tests/gdimageclone/CMakeLists.txt index e6ccc31..662f4e9 100644 --- a/tests/gdimageclone/CMakeLists.txt +++ b/tests/gdimageclone/CMakeLists.txt @@ -1,5 +1,6 @@ LIST(APPEND TESTS_FILES bug00300 + style ) ADD_GD_TESTS() diff --git a/tests/gdimageclone/Makemodule.am b/tests/gdimageclone/Makemodule.am index 4b1b54c..51abf5c 100644 --- a/tests/gdimageclone/Makemodule.am +++ b/tests/gdimageclone/Makemodule.am @@ -1,5 +1,6 @@ libgd_test_programs += \ - gdimageclone/bug00300 + gdimageclone/bug00300 \ + gdimageclone/style EXTRA_DIST += \ gdimageclone/CMakeLists.txt diff --git a/tests/gdimageclone/style.c b/tests/gdimageclone/style.c new file mode 100644 index 0000000..c2b246e --- /dev/null +++ b/tests/gdimageclone/style.c @@ -0,0 +1,30 @@ +/** + * Cloning an image should exactly reproduce all style related data + */ + + +#include <string.h> +#include "gd.h" +#include "gdtest.h" + + +int main() +{ + gdImagePtr im, clone; + int style[] = {0, 0, 0}; + + im = gdImageCreate(8, 8); + gdImageSetStyle(im, style, sizeof(style)/sizeof(style[0])); + + clone = gdImageClone(im); + gdTestAssert(clone != NULL); + + gdTestAssert(clone->styleLength == im->styleLength); + gdTestAssert(clone->stylePos == im->stylePos); + gdTestAssert(!memcmp(clone->style, im->style, sizeof(style)/sizeof(style[0]))); + + gdImageDestroy(clone); + gdImageDestroy(im); + + return gdNumFailures(); +} |