diff options
author | Pierre Joye <pierre.php@gmail.com> | 2022-02-01 15:09:01 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-01 15:09:01 +0700 |
commit | 167ea1f4f0003f3e9f7ca1e586189e99cf33d47f (patch) | |
tree | a21a237b619b048e0c6d88388744cf9f029d47ae /tests/gdimagecolorexact | |
parent | 3d760c2c213f7a63dbe13792262406177cd9738a (diff) | |
download | libgd-167ea1f4f0003f3e9f7ca1e586189e99cf33d47f.tar.gz |
Fix tests based on coverity reports (#819)
* Partial #818, unused arg
* Partial #818, init var
* partail #818, fix va_args usage
* partail #818, handle f* calls and avoid possible call to malloc with negative values
* partail #818, prevent double free
* partail #818, resource leak if test fail
* partail #818, null deref fix
* partail #818, avoid double free on fp failure
* Partial #818, fix error msg
* Partial #818, leak on error
* Partial #818, null deref
* Partial #818, avoid possible negative index on failure
* partial #818, does not free if we return if requested new size overflow
* partial #818, avoid double free, free where the alloc happened
Diffstat (limited to 'tests/gdimagecolorexact')
-rw-r--r-- | tests/gdimagecolorexact/gdimagecolorexact.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/tests/gdimagecolorexact/gdimagecolorexact.c b/tests/gdimagecolorexact/gdimagecolorexact.c index 9d754ca..e127b84 100644 --- a/tests/gdimagecolorexact/gdimagecolorexact.c +++ b/tests/gdimagecolorexact/gdimagecolorexact.c @@ -30,34 +30,32 @@ int main() c3 = gdImageColorExactAlpha(im, 255, 0, 255, 100); c4 = gdImageColorExactAlpha(im, 255, 34, 255, 100); + if (gdTestAssert(c1 == 0) != 1) { - error = -1; + color = gdTrueColorAlpha(gdImageRed(im, c1), gdImageGreen(im, c1), + gdImageBlue(im, c1), 0); + if (gdTestAssert(color == 0xFF00FF) != 1) { + error = -1; + } } if (gdTestAssert(c2 == 1) != 1) { - error = -1; + color = gdTrueColorAlpha(gdImageRed(im, c2), gdImageGreen(im, c2), + gdImageBlue(im, c2), 0); + if (gdTestAssert(color == 0xFFC800) != 1) { + error = -1; + } } if (gdTestAssert(c3 == 2) != 1) { - error = -1; + color = gdTrueColorAlpha(gdImageRed(im, c3), gdImageGreen(im, c3), + gdImageBlue(im, c3), 0); + if (gdTestAssert(color == 0xFF00FF) != 1) { + error = -1; + } } if (gdTestAssert(c4 == -1) != 1) { error = -1; } - color = gdTrueColorAlpha(gdImageRed(im, c1), gdImageGreen(im, c1), - gdImageBlue(im, c1), 0); - if (gdTestAssert(color == 0xFF00FF) != 1) { - error = -1; - } - color = gdTrueColorAlpha(gdImageRed(im, c2), gdImageGreen(im, c2), - gdImageBlue(im, c2), 0); - if (gdTestAssert(color == 0xFFC800) != 1) { - error = -1; - } - color = gdTrueColorAlpha(gdImageRed(im, c3), gdImageGreen(im, c3), - gdImageBlue(im, c3), 0); - if (gdTestAssert(color == 0xFF00FF) != 1) { - error = -1; - } gdImageDestroy(im); return error; |