@@ -168,6 +168,7 @@ static int yaml_path_query(const char *filepath, const char *yaml_path_cstr, str
168
168
yaml_parser_set_input_file (& parser , yaml_file );
169
169
170
170
yaml_event_t event ;
171
+ yaml_event_type_t event_type ;
171
172
bool sequence = false;
172
173
173
174
do {
@@ -181,16 +182,16 @@ static int yaml_path_query(const char *filepath, const char *yaml_path_cstr, str
181
182
ret = -1 ;
182
183
goto cleanup ;
183
184
}
185
+
186
+ event_type = event .type ;
184
187
if (!yaml_path_filter_event (yaml_path , & parser , & event ,
185
188
YAML_PATH_FILTER_RETURN_ALL )) {
186
- yaml_event_delete (& event );
187
- continue ;
189
+ goto next ;
188
190
}
189
-
190
191
if (sequence ) {
191
- if (event . type == YAML_SEQUENCE_END_EVENT ) {
192
+ if (event_type == YAML_SEQUENCE_END_EVENT ) {
192
193
sequence = false;
193
- } else if (event . type != YAML_SCALAR_EVENT ) {
194
+ } else if (event_type != YAML_SCALAR_EVENT ) {
194
195
SEXP_t * msg = probe_msg_creatf (OVAL_MESSAGE_LEVEL_ERROR ,
195
196
"YAML path '%s' contains non-scalar in a sequence." ,
196
197
yaml_path_cstr );
@@ -201,10 +202,10 @@ static int yaml_path_query(const char *filepath, const char *yaml_path_cstr, str
201
202
goto cleanup ;
202
203
}
203
204
} else {
204
- if (event . type == YAML_SEQUENCE_START_EVENT ) {
205
+ if (event_type == YAML_SEQUENCE_START_EVENT ) {
205
206
sequence = true;
206
207
}
207
- if (event . type == YAML_MAPPING_START_EVENT ) {
208
+ if (event_type == YAML_MAPPING_START_EVENT ) {
208
209
SEXP_t * msg = probe_msg_creatf (OVAL_MESSAGE_LEVEL_ERROR ,
209
210
"YAML path '%s' matches a mapping." ,
210
211
yaml_path_cstr );
@@ -215,7 +216,7 @@ static int yaml_path_query(const char *filepath, const char *yaml_path_cstr, str
215
216
goto cleanup ;
216
217
}
217
218
}
218
- if (event . type == YAML_SCALAR_EVENT ) {
219
+ if (event_type == YAML_SCALAR_EVENT ) {
219
220
SEXP_t * sexp = yaml_scalar_event_to_sexp (& event );
220
221
if (sexp == NULL ) {
221
222
SEXP_t * msg = probe_msg_creatf (OVAL_MESSAGE_LEVEL_ERROR ,
@@ -229,7 +230,9 @@ static int yaml_path_query(const char *filepath, const char *yaml_path_cstr, str
229
230
}
230
231
oscap_list_add (values , sexp );
231
232
}
232
- } while (event .type != YAML_STREAM_END_EVENT );
233
+ next :
234
+ yaml_event_delete (& event );
235
+ } while (event_type != YAML_STREAM_END_EVENT );
233
236
234
237
cleanup :
235
238
yaml_parser_delete (& parser );
0 commit comments