[CVE-2018-14553] Fix potential NULL pointer dereference in gdImageClone() 43/309343/2 accepted/tizen_base accepted/tizen_base_asan accepted/tizen_base_toolchain accepted/tizen_base_x tizen_base accepted/tizen/base/20240415.081831 accepted/tizen/base/asan/20240422.014824 accepted/tizen/base/toolchain/20240424.234645 accepted/tizen/base/x/20240416.082023
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 9 Apr 2024 02:18:01 +0000 (11:18 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 9 Apr 2024 02:32:49 +0000 (11:32 +0900)
https://github.com/libgd/libgd/commit/a93eac0e843148dc2d631c3ba80af17e9c8c860f

Change-Id: Ie7339ccad3475ca5e5ee2535217f1474b88108e7

deps/libmscgen/gd.c

index a9a8aa6..7176783 100644 (file)
@@ -2855,14 +2855,6 @@ BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) {
                }
        }
 
-       if (src->styleLength > 0) {
-               dst->styleLength = src->styleLength;
-               dst->stylePos    = src->stylePos;
-               for (i = 0; i < src->styleLength; i++) {
-                       dst->style[i] = src->style[i];
-               }
-       }
-
        dst->interlace   = src->interlace;
 
        dst->alphaBlendingFlag = src->alphaBlendingFlag;
@@ -2897,6 +2889,7 @@ BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) {
 
        if (src->style) {
                gdImageSetStyle(dst, src->style, src->styleLength);
+        dst->stylePos = src->stylePos;
        }
 
        for (i = 0; i < gdMaxColors; i++) {