*
* LGPL HEADER END
*
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2014, 2015, Intel Corporation.
*
* Author:
* Amir Shehata <amir.shehata@intel.com>
static enum cYAML_handler_error yaml_stream_end(yaml_token_t *token,
struct cYAML_tree_node *tree)
{
- if (tree->state != TREE_STATE_TREE_STARTED)
+ if (tree->state != TREE_STATE_TREE_STARTED &&
+ tree->state != TREE_STATE_COMPLETE)
return CYAML_ERROR_UNEXPECTED_STATE;
tree->state = TREE_STATE_INITED;
struct cYAML_print_info *cpi = NULL;
struct cYAML *node = cYAML_ll_pop(stack, &cpi);
+ if (node == NULL)
+ return;
+
switch (node->cy_type) {
case CYAML_TYPE_FALSE:
case CYAML_TYPE_TRUE:
goto failed;
if (seq_no >= 0 &&
- cYAML_create_number(err, "seqno", seq_no) == NULL)
+ cYAML_create_number(err, "seq_no", seq_no) == NULL)
goto failed;
if (cYAML_create_number(err, "errno", rc) == NULL)
return;
failed:
+ /* Only reason we get here is if we run out of memory */
cYAML_free_tree(r);
r = NULL;
+ fprintf(stderr, "error:\n\tfatal: out of memory\n");
}
struct cYAML *cYAML_build_tree(char *yaml_file,
/* Create the Parser object. */
yaml_parser_initialize(&parser);
- /* file alwyas takes precedence */
+ /* file always takes precedence */
if (yaml_file != NULL) {
/* Set a file input. */
input = fopen(yaml_file, "rb");