mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
parse_set and parse_unset: restore stomped char before returning
The parsing in parse_set and parse_unset saves, overwrites with a NUL, and restores a character in the string that is being parsed. If there is a malloc failure between overwriting and restoring, the restore is not done. This commit changes that behaviour to restore before returning.
This commit is contained in:
parent
fa12b10e26
commit
8a8be53452
@ -105,8 +105,8 @@ parse_set(struct option *opt_tree, unsigned char **file, int *line,
|
||||
bin = **file;
|
||||
**file = '\0';
|
||||
optname = stracpy(optname);
|
||||
if (!optname) return ERROR_NOMEM;
|
||||
**file = bin;
|
||||
if (!optname) return ERROR_NOMEM;
|
||||
|
||||
*file = skip_white(*file, line);
|
||||
|
||||
@ -180,8 +180,8 @@ parse_unset(struct option *opt_tree, unsigned char **file, int *line,
|
||||
bin = **file;
|
||||
**file = '\0';
|
||||
optname = stracpy(optname);
|
||||
if (!optname) return ERROR_NOMEM;
|
||||
**file = bin;
|
||||
if (!optname) return ERROR_NOMEM;
|
||||
|
||||
/* Mirror what we have */
|
||||
if (mirror) add_bytes_to_string(mirror, orig_pos, *file - orig_pos);
|
||||
|
Loading…
x
Reference in New Issue
Block a user