forked from external/yambar
yml: don’t overwrite errors from yml_parser_parse()
When we detect an error in yml_parser_parse(), we handle that specifically, and then jump to the generic error handler. The generic error handler overwrites the previously formatted error before cleaning up and returning. This meant that a) the actual error message was lost, and replaced with a generic “unknown error”, and b) the dynamically allocated error string buffer was leaked.
This commit is contained in:
parent
57e755477c
commit
eceee99fb0
2 changed files with 8 additions and 1 deletions
|
@ -9,6 +9,11 @@
|
|||
### Deprecated
|
||||
### Removed
|
||||
### Fixed
|
||||
|
||||
* YAML parsing error messages being replaced with a generic “unknown error”.
|
||||
* Memory leak when a YAML parsing error was encoutered.
|
||||
|
||||
|
||||
### Security
|
||||
### Contributors
|
||||
|
||||
|
|
4
yml.c
4
yml.c
|
@ -383,7 +383,7 @@ yml_load(FILE *yml, char **error)
|
|||
yaml.context != NULL ? yaml.context : "");
|
||||
}
|
||||
|
||||
goto err;
|
||||
goto err_no_error_formatting;
|
||||
}
|
||||
|
||||
switch (event.type) {
|
||||
|
@ -550,6 +550,8 @@ err:
|
|||
yaml.mark.line + 1, yaml.mark.column);
|
||||
}
|
||||
|
||||
err_no_error_formatting:
|
||||
|
||||
yml_destroy(root);
|
||||
yaml_parser_delete(&yaml);
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue