make StringValue wrapper okay to call on NULL

The docs say "don't do this", but it's trivial to make safe.  Make
StringValue(NULL) return NULL instead of crashing.

Change-Id: I2221bcb4c98d8adb4e25c764d7bdcfa787822bcf
This commit is contained in:
Doug Zongker 2010-02-24 15:03:47 -08:00
parent c4351c7910
commit 5b695f393e

View File

@ -50,6 +50,7 @@ Value* EvaluateValue(State* state, Expr* expr) {
}
Value* StringValue(char* str) {
if (str == NULL) return NULL;
Value* v = malloc(sizeof(Value));
v->type = VAL_STRING;
v->size = strlen(str);