Skip to content

Commit

Permalink
Fixed memory release on error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhainin authored and bd808 committed Mar 5, 2023
1 parent d9803e6 commit 2085414
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions parse.c
Expand Up @@ -467,6 +467,7 @@ void handle_mapping(parser_state_t *state, zval *retval)
state->parser.mark.line + 1,
state->parser.mark.column + 1
);
zval_ptr_dtor(&value);
break;
}
}
Expand Down Expand Up @@ -518,8 +519,10 @@ void handle_sequence (parser_state_t *state, zval *retval) {
}

if (YAML_SEQUENCE_END_EVENT != state->event.type) {
//TODO Sean-Der
zval_ptr_dtor(retval);
ZVAL_UNDEF(retval);
goto done;
//TODO Sean-Der
//zval_ptr_dtor(&retval);
//retval = NULL;
}
Expand All @@ -528,13 +531,15 @@ void handle_sequence (parser_state_t *state, zval *retval) {
/* apply callbacks to the collected node */
if (Y_FILTER_FAILURE == apply_filter(
retval, src_event, state->callbacks)) {
//TODO Sean-Der
zval_ptr_dtor(&retval);

This comment has been minimized.

Copy link
@remicollet

remicollet Mar 6, 2023

Contributor

this raise an -Wincompatible-pointer-types warning

This comment has been minimized.

Copy link
@remicollet

remicollet Mar 6, 2023

Contributor

see PR #74

ZVAL_UNDEF(retval);
//zval_ptr_dtor(&retval);
goto done;
//TODO Sean-Der
//retval = NULL;
}
}

done:
yaml_event_delete(&src_event);
}
/* }}} */
Expand Down

0 comments on commit 2085414

Please sign in to comment.