From: Luigi Rizzo Date: Mon, 11 Dec 2006 18:11:58 +0000 (+0000) Subject: make sure the argument to ast_malloc() is > 0. X-Git-Tag: 1.6.0-beta1~3^2~3754 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6c706c71bff89efdf5eceed9405a4b78b100ec1;p=thirdparty%2Fasterisk.git 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: https://origsvn.digium.com/svn/asterisk/trunk@48389 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/manager.c b/main/manager.c index 269f708d49..a0ecbd83ec 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", "