From cb7f99b4c96ecb53f87ab0863c2a9b4935540a36 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 27 May 2008 01:24:13 +0000 Subject: [PATCH] cpp_scope_pop() now handles platforms where realloc(a, 0) returns NULL --- src/cpp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cpp.c b/src/cpp.c index 0af2575..39ec399 100644 --- a/src/cpp.c +++ b/src/cpp.c @@ -411,7 +411,12 @@ static int _cpp_scope_pop(Cpp * cpp) CppScope * p; 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) return error_set_code(1, "%s", strerror(errno)); cpp->scopes = p;