svg_loader SvgLoader: Prevent memory leak
authorJunsuChoi <jsuya.choi@samsung.com>
Mon, 1 Feb 2021 04:22:44 +0000 (13:22 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Tue, 2 Feb 2021 10:19:13 +0000 (19:19 +0900)
When OOM of SvgLinear/RadialGradient occurs,
the allocated id, ref, transform may become a memory leak.
Therefore, add free memory.

src/loaders/svg/tvgSvgLoader.cpp

index e421c39..59f10cf 100644 (file)
@@ -1535,6 +1535,9 @@ static SvgStyleGradient* _cloneGradient(SvgStyleGradient* from)
     return grad;
 error_grad_alloc:
     //LOG: allocation failed. out of memory
+    if (grad->transform) free(grad->transform);
+    if (grad->ref) delete grad->ref;
+    if (grad->id) delete grad->id;
     if (grad) free(grad);
     return nullptr;
 }