From 8a8be5345223eae915de60bc9a9dbc98fdc4d4a6 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Tue, 28 Aug 2007 17:47:59 +0000 Subject: [PATCH] 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. --- src/config/conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/conf.c b/src/config/conf.c index 94e28c69..3c03830c 100644 --- a/src/config/conf.c +++ b/src/config/conf.c @@ -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);