Convert some broken cases where Error is called, but we try to continue,

to Fatal errors, because the logic that we use to try to continue is far
too broken, and makes things look and act weird, because we end up pointing
past the end of a buffer boundry into freed memory in the caller, as we
don't come close to setting the lengthPtr to a sane value.

Reviewed by:	make@

(This only changes failure cases which would have died horrid deaths to
 explicit clean death failure cases.)
This commit is contained in:
Juli Mallett 2002-11-08 16:59:11 +00:00
parent 11af41920e
commit 15ac7b352e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106642

View File

@ -1268,17 +1268,11 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
/*
* If lhs didn't end with the delimiter, complain and
* return NULL
* exit.
*/
if (*cp != del) {
*lengthPtr = cp - start + 1;
if (*freePtr) {
free(str);
}
Buf_Destroy(buf, TRUE);
Error("Unclosed substitution for %s (%c missing)",
Fatal("Unclosed substitution for %s (%c missing)",
v->name, del);
return (var_Error);
}
/*
@ -1336,14 +1330,8 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
* If didn't end in delimiter character, complain
*/
if (*cp != del) {
*lengthPtr = cp - start + 1;
if (*freePtr) {
free(str);
}
Buf_Destroy(buf, TRUE);
Error("Unclosed substitution for %s (%c missing)",
Fatal("Unclosed substitution for %s (%c missing)",
v->name, del);
return (var_Error);
}
pattern.rhs = (char *)Buf_GetAll(buf, &pattern.rightLen);
@ -1390,7 +1378,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
if (*freePtr)
free(str);
if (delim != '\0')
Error("Unclosed substitution for %s (%c missing)",
Fatal("Unclosed substitution for %s (%c missing)",
v->name, delim);
return (var_Error);
}
@ -1404,7 +1392,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
if (*freePtr)
free(str);
if (delim != '\0')
Error("Unclosed substitution for %s (%c missing)",
Fatal("Unclosed substitution for %s (%c missing)",
v->name, delim);
return (var_Error);
}