cpp_scope_pop() now handles platforms where realloc(a, 0) returns NULL
This commit is contained in:
parent
184130ccf0
commit
cb7f99b4c9
|
@ -411,7 +411,12 @@ static int _cpp_scope_pop(Cpp * cpp)
|
||||||
CppScope * p;
|
CppScope * p;
|
||||||
|
|
||||||
assert(cpp->scopes_cnt > 0);
|
assert(cpp->scopes_cnt > 0);
|
||||||
if((p = realloc(cpp->scopes, sizeof(*p) * (cpp->scopes_cnt - 1)))
|
if(cpp->scopes_cnt == 1)
|
||||||
|
{
|
||||||
|
free(cpp->scopes);
|
||||||
|
p = NULL;
|
||||||
|
}
|
||||||
|
else if((p = realloc(cpp->scopes, sizeof(*p) * (cpp->scopes_cnt - 1)))
|
||||||
== NULL)
|
== NULL)
|
||||||
return error_set_code(1, "%s", strerror(errno));
|
return error_set_code(1, "%s", strerror(errno));
|
||||||
cpp->scopes = p;
|
cpp->scopes = p;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user