From e823e89b5a975a4d6effd57db2ba1e106dff6300 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Thu, 10 Jan 2008 19:03:04 +0000 Subject: [PATCH] Check pointers before freeing (was getting WARNINGS under MALLOC_DEBUG) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@97825 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/ast_expr2f.c | 3 ++- main/cli.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/main/ast_expr2f.c b/main/ast_expr2f.c index 57eb2dd5bb..9f5e5cf4f4 100644 --- a/main/ast_expr2f.c +++ b/main/ast_expr2f.c @@ -3963,7 +3963,8 @@ void *ast_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) void ast_yyfree (void * ptr , yyscan_t yyscanner) { - free( (char *) ptr ); /* see ast_yyrealloc() for (char *) cast */ + if (ptr) + free( (char *) ptr ); /* see ast_yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" diff --git a/main/cli.c b/main/cli.c index 72cd8152f4..8813c6a3f2 100644 --- a/main/cli.c +++ b/main/cli.c @@ -135,7 +135,8 @@ static char *complete_fn(const char *word, int state) c += (strlen(ast_config_AST_MODULE_DIR) + 1); if (c) c = ast_strdup(c); - free(d); + if (d) + free(d); return c; } -- 2.47.2