Skip to content

Commit 2191e66

Browse files
committed
fixed mem leak in sgv parse error
1 parent c34fe92 commit 2191e66

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

Diff for: src/scene_manager/loader_svg.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ static Bool svg_parse_animation(GF_SVG_Parser *parser, GF_SceneGraph *sg, SVG_De
449449
if (anim->to) {
450450
/* now that we have a target, if there is a to value to parse, create the attribute and parse it */
451451
gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_to, GF_TRUE, GF_FALSE, &info);
452+
if (!info.name) info.name = "to";
452453
gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->to, anim_value_type);
453454
if (anim_value_type==XMLRI_datatype) {
454455
svg_post_process_href(parser, (GF_Node *) anim->target, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value);
@@ -457,20 +458,23 @@ static Bool svg_parse_animation(GF_SVG_Parser *parser, GF_SceneGraph *sg, SVG_De
457458
if (anim->from) {
458459
/* now that we have a target, if there is a from value to parse, create the attribute and parse it */
459460
gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_from, GF_TRUE, GF_FALSE, &info);
461+
if (!info.name) info.name = "from";
460462
gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->from, anim_value_type);
461463
if (anim_value_type==XMLRI_datatype)
462464
svg_post_process_href(parser, (GF_Node *) anim->target, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value);
463465
}
464466
if (anim->by) {
465467
/* now that we have a target, if there is a by value to parse, create the attribute and parse it */
466468
gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_by, GF_TRUE, GF_FALSE, &info);
469+
if (!info.name) info.name = "by";
467470
gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->by, anim_value_type);
468471
if (anim_value_type==XMLRI_datatype)
469472
svg_post_process_href(parser, (GF_Node *) anim->target, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value);
470473
}
471474
if (anim->values) {
472475
/* now that we have a target, if there is a 'values' value to parse, create the attribute and parse it */
473476
gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_values, GF_TRUE, GF_FALSE, &info);
477+
if (!info.name) info.name = "values";
474478
gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->values, anim_value_type);
475479
if (anim_value_type==XMLRI_datatype) {
476480
u32 i, count;
@@ -2119,13 +2123,13 @@ GF_Err load_svg_run(GF_SceneLoader *load)
21192123

21202124
in_time = gf_sys_clock();
21212125
e = gf_xml_sax_parse_file(parser->sax_parser, (const char *)load->fileName, svg_progress);
2126+
svg_flush_animations(parser);
2127+
gf_sm_svg_flush_state(parser);
21222128
if (parser->last_error<0) e = parser->last_error;
2123-
2129+
21242130
if (e<0) return svg_report(parser, e, "Unable to parse file %s: %s", load->fileName, gf_xml_sax_get_error(parser->sax_parser) );
21252131
GF_LOG(GF_LOG_INFO, GF_LOG_PARSER, ("[Parser] Scene parsed and Scene Graph built in %d ms\n", gf_sys_clock() - in_time));
21262132

2127-
svg_flush_animations(parser);
2128-
gf_sm_svg_flush_state(parser);
21292133
return e;
21302134

21312135
}

Diff for: src/scenegraph/svg_attributes.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -2994,7 +2994,7 @@ static void svg_parse_preserveaspectratio(SVG_PreserveAspectRatio *par, char *at
29942994
while (*content == ' ') content++;
29952995
if (strstr(content, "defer")) {
29962996
par->defer = 1;
2997-
content += 4;
2997+
content += 5;
29982998
} else {
29992999
content = attribute_content;
30003000
}
@@ -3587,11 +3587,14 @@ GF_Err gf_svg_parse_attribute(GF_Node *n, GF_FieldInfo *info, char *attribute_co
35873587
*(SVG_String *)info->far_ptr = gf_strdup(attribute_content);
35883588
break;
35893589
default:
3590-
GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[SVG Parsing] Cannot parse attribute %s\n", info->name ? info->name : ""));
3591-
break;
3590+
GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[SVG Parsing] Cannot parse attribute \"%s\"\n", info->name ? info->name : ""));
3591+
return GF_OK;
35923592
}
35933593
if (e) {
3594-
GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Cannot parse attribute %s value %s: %s\n", info->name ? info->name : "", attribute_content, gf_error_to_string(e)));
3594+
GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[SVG Parsing] Cannot parse attribute \"%s\" value %s: %s\n", info->name ? info->name : "", attribute_content, gf_error_to_string(e)));
3595+
//continue parsing if not test mode
3596+
if (!gf_sys_is_test_mode())
3597+
e = GF_OK;
35953598
}
35963599
return e;
35973600
}

0 commit comments

Comments
 (0)