svg_loader: multiple composition memory leak
authorMichal Maciola <m.maciola@samsung.com>
Thu, 1 Jul 2021 09:29:22 +0000 (11:29 +0200)
committerJunsuChoi <jsuya.choi@samsung.com>
Wed, 7 Jul 2021 02:57:02 +0000 (11:57 +0900)
Multiple composition are still not supported, but this patch fixes a
memory leak if it is tried to be applied.

src/loaders/svg/tvgSvgLoader.cpp

index cbf000b9dcdfb561f045c9e61e77e46db5f815fb..9a3ac4266da36a97c1e2c40b3cb4f78125a0177a 100644 (file)
@@ -869,7 +869,11 @@ static void _handleClipPathAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node,
 #endif
     style->comp.method = CompositeMethod::ClipPath;
     int len = strlen(value);
-    if (len >= 3 && !strncmp(value, "url", 3)) style->comp.url = _idFromUrl((const char*)(value + 3));
+    if (len >= 3 && !strncmp(value, "url", 3)) {
+        //FIXME: Support multiple composition.
+        if (style->comp.url) delete(style->comp.url);
+        style->comp.url = _idFromUrl((const char*)(value + 3));
+    }
 }