@@ -336,12 +336,12 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
336336
337337 r = lyp_fill_attr (ctx , * result , str , NULL , attr -> name , attr -> value , xml , options , & dattr );
338338 if (r == -1 ) {
339- goto error ;
339+ goto unlink_node_error ;
340340 } else if (r == 1 ) {
341341attr_error :
342342 if (options & LYD_OPT_STRICT ) {
343343 LOGVAL (ctx , LYE_INATTR , LY_VLOG_LYD , * result , attr -> name );
344- goto error ;
344+ goto unlink_node_error ;
345345 }
346346
347347 LOGWRN (ctx , "Unknown \"%s:%s\" metadata with value \"%s\", ignoring." ,
@@ -355,7 +355,7 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
355355 if (!dattr -> value .string ) {
356356 /* problem with resolving value as xpath */
357357 dattr -> value .string = dattr -> value_str ;
358- goto error ;
358+ goto unlink_node_error ;
359359 }
360360 lydict_remove (ctx , dattr -> value_str );
361361 dattr -> value_str = dattr -> value .string ;
@@ -374,7 +374,7 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
374374 /* check insert attribute and its values */
375375 if (options & LYD_OPT_EDIT ) {
376376 if (lyp_check_edit_attr (ctx , (* result )-> attr , * result , & editbits )) {
377- goto error ;
377+ goto unlink_node_error ;
378378 }
379379
380380 /* check correct filter extension attributes */
@@ -384,14 +384,14 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
384384 if (!strcmp (dattr_iter -> name , "type" )) {
385385 if ((found == 1 ) || (found == 2 ) || (found == 4 )) {
386386 LOGVAL (ctx , LYE_TOOMANY , LY_VLOG_LYD , (* result ), "type" , xml -> name );
387- goto error ;
387+ goto unlink_node_error ;
388388 }
389389 switch (dattr_iter -> value .enm -> value ) {
390390 case 0 :
391391 /* subtree */
392392 if (found == 3 ) {
393393 LOGVAL (ctx , LYE_INATTR , LY_VLOG_LYD , (* result ), dattr_iter -> name );
394- goto error ;
394+ goto unlink_node_error ;
395395 }
396396
397397 assert (!found );
@@ -408,7 +408,7 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
408408 break ;
409409 default :
410410 LOGINT (ctx );
411- goto error ;
411+ goto unlink_node_error ;
412412 }
413413 } else if (!strcmp (dattr_iter -> name , "select" )) {
414414 switch (found ) {
@@ -417,17 +417,17 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
417417 break ;
418418 case 1 :
419419 LOGVAL (ctx , LYE_INATTR , LY_VLOG_LYD , (* result ), dattr_iter -> name );
420- goto error ;
420+ goto unlink_node_error ;
421421 case 2 :
422422 found = 4 ;
423423 break ;
424424 case 3 :
425425 case 4 :
426426 LOGVAL (ctx , LYE_TOOMANY , LY_VLOG_LYD , (* result ), "select" , xml -> name );
427- goto error ;
427+ goto unlink_node_error ;
428428 default :
429429 LOGINT (ctx );
430- goto error ;
430+ goto unlink_node_error ;
431431 }
432432 }
433433 }
@@ -440,21 +440,21 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
440440 break ;
441441 case 2 :
442442 LOGVAL (ctx , LYE_MISSATTR , LY_VLOG_LYD , (* result ), "select" , xml -> name );
443- goto error ;
443+ goto unlink_node_error ;
444444 case 3 :
445445 LOGVAL (ctx , LYE_MISSATTR , LY_VLOG_LYD , (* result ), "type" , xml -> name );
446- goto error ;
446+ goto unlink_node_error ;
447447 default :
448448 LOGINT (ctx );
449- goto error ;
449+ goto unlink_node_error ;
450450 }
451451 }
452452
453453 /* type specific processing */
454454 if (schema -> nodetype & (LYS_LEAF | LYS_LEAFLIST )) {
455455 /* type detection and assigning the value */
456456 if (xml_get_value (* result , xml , editbits , options & LYD_OPT_TRUSTED )) {
457- goto error ;
457+ goto unlink_node_error ;
458458 }
459459 } else if (schema -> nodetype & LYS_ANYDATA ) {
460460 /* store children values */
@@ -478,14 +478,14 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
478478 LOGVAL (ctx , LYE_INELEM , LY_VLOG_LYD , (* result ), schema -> name );
479479 LOGVAL (ctx , LYE_SPEC , LY_VLOG_PREV , NULL , "Unexpected %s node \"%s\"." ,
480480 (schema -> nodetype == LYS_RPC ? "rpc" : "action" ), schema -> name );
481- goto error ;
481+ goto unlink_node_error ;
482482 }
483483 * act_notif = * result ;
484484 } else if (schema -> nodetype == LYS_NOTIF ) {
485485 if (!(options & LYD_OPT_NOTIF ) || * act_notif ) {
486486 LOGVAL (ctx , LYE_INELEM , LY_VLOG_LYD , (* result ), schema -> name );
487487 LOGVAL (ctx , LYE_SPEC , LY_VLOG_PREV , NULL , "Unexpected notification node \"%s\"." , schema -> name );
488- goto error ;
488+ goto unlink_node_error ;
489489 }
490490 * act_notif = * result ;
491491 }
@@ -541,6 +541,8 @@ xml_parse_data(struct ly_ctx *ctx, struct lyxml_elem *xml, struct lyd_node *pare
541541
542542 return ret ;
543543
544+ unlink_node_error :
545+ lyd_unlink_internal (* result , 2 );
544546error :
545547 /* cleanup */
546548 for (i = unres -> count - 1 ; i >= 0 ; i -- ) {
0 commit comments