diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-11 18:11:58 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-12-11 18:11:58 +0000 |
commit | fcafc05f7e4cb7563d585d301777fe1c5880544d (patch) | |
tree | 80f167a88ae1daaca80c345d35435935fa300fe0 | |
parent | 75b14fe36b1ab92f68ee0e1bb17298ef8f44c061 (diff) |
make sure the argument to ast_malloc() is > 0.
Long explaination:
The behaviour of the underlying malloc(0) differs depending on the
operating system. Some return NULL (SysV behaviour); some still
allocate a small chunk of memory and return a valid pointer (e.g.
traditional BSD); some (e.g. FreeBSD 6.x) return a non-null pointer
that causes a memory fault if used, even just for reading.
Given the above variety, better never call malloc(0).
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@48389 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | main/manager.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/main/manager.c b/main/manager.c index 269f708d4..a0ecbd83e 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2599,7 +2599,7 @@ static char *xml_translate(char *in, struct ast_variable *vars, enum output_form else if (strchr("&\"<>", in[x])) escaped++; } - len = (size_t) (strlen(in) + colons * 5 + breaks * (40 + strlen(dest) + strlen(objtype)) + escaped * 10); /* foo="bar", "<response type=\"object\" id=\"dest\"", "&" */ + len = (size_t) (1 + strlen(in) + colons * 5 + breaks * (40 + strlen(dest) + strlen(objtype)) + escaped * 10); /* foo="bar", "<response type=\"object\" id=\"dest\"", "&" */ out = ast_malloc(len); if (!out) return NULL; |