svg/loader: Fix memory leak
authorSubhransu Mohanty <smohantty@gmail.com>
Mon, 1 Jun 2020 09:53:36 +0000 (18:53 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 1 Jun 2020 20:59:27 +0000 (05:59 +0900)
Reviewers: Hermet

Reviewed By: Hermet

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11908

src/modules/evas/vg_loaders/svg/evas_vg_load_svg.c
src/static_libs/vg_common/vg_common_svg.c

index 313d3ee..9151e05 100644 (file)
@@ -2410,6 +2410,7 @@ static Eina_Bool
 evas_vg_load_file_close_svg(Vg_File_Data *vfd)
 {
    if (vfd->root) efl_unref(vfd->root);
+   free(vfd);
    return EINA_TRUE;
 }
 
@@ -2462,7 +2463,9 @@ evas_vg_load_file_open_svg(Eina_File *file,
      }
    free(loader.svg_parse);
 
-   return vg_common_svg_create_vg_node(loader.doc);
+   Vg_File_Data* result = vg_common_svg_create_vg_node(loader.doc);
+   vg_common_svg_node_free(loader.doc);
+   return result;
 }
 
 static Evas_Vg_Load_Func evas_vg_load_svg_func =
index de5477b..058cdf9 100644 (file)
@@ -536,12 +536,14 @@ vg_common_svg_node_free(Svg_Node *node)
              {
                 _svg_style_gradient_free(grad);
              }
+        case SVG_NODE_CUSTOME_COMMAND:
+           if (node->node.command.commands) free(node->node.command.commands);
+           if (node->node.command.points) free(node->node.command.points);         
            break;
         default:
            break;
      }
-   if (node->node.command.commands_count > 0) free(node->node.command.commands);
-   if (node->node.command.points_count > 0) free(node->node.command.points);
+
    free(node);
 }