1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-07-02 02:15:28 +00: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:
Miciah Dashiel Butler Masters 2007-08-28 17:47:59 +00:00 committed by Miciah Dashiel Butler Masters
parent fa12b10e26
commit 8a8be53452

View File

@ -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);