[sr-dev] git:master:cfcc10a8: app_python: adjusted the realloc size to char pointers

Daniel-Constantin Mierla miconda at gmail.com
Wed Nov 2 09:45:49 CET 2016


Module: kamailio
Branch: master
Commit: cfcc10a809feb89c2365c6cacec72ae01ee3888a
URL: https://github.com/kamailio/kamailio/commit/cfcc10a809feb89c2365c6cacec72ae01ee3888a

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-11-01T18:11:17+01:00

app_python: adjusted the realloc size to char pointers

---

Modified: modules/app_python/python_support.c

---

Diff:  https://github.com/kamailio/kamailio/commit/cfcc10a809feb89c2365c6cacec72ae01ee3888a.diff
Patch: https://github.com/kamailio/kamailio/commit/cfcc10a809feb89c2365c6cacec72ae01ee3888a.patch

---

diff --git a/modules/app_python/python_support.c b/modules/app_python/python_support.c
index 28f92da..47b4640 100644
--- a/modules/app_python/python_support.c
+++ b/modules/app_python/python_support.c
@@ -184,14 +184,14 @@ char *make_message(const char *fmt, ...)
 	va_list ap;
 
 	size = 100;     /* Guess we need no more than 100 bytes. */
-	p = (char *)pkg_realloc(NULL, size * sizeof(char *));
+	p = (char *)pkg_realloc(NULL, size * sizeof(char));
 	if (!p)
 	{
 		LM_ERR("Can't allocate memory (%lu bytes), pkg_malloc() has failed:"
-				" Not enough memory.\n", (unsigned long)(size * sizeof(char *)));
+				" Not enough memory.\n", (unsigned long)(size * sizeof(char)));
 		return NULL;
 	}
-	memset(p, 0, size * sizeof(char *));
+	memset(p, 0, size * sizeof(char));
 
 	while (1)
 	{
@@ -207,11 +207,11 @@ char *make_message(const char *fmt, ...)
 		else           /* glibc 2.0 */
 			size *= 2;
 
-		np = (char *)pkg_realloc(p, size * sizeof(char *));
+		np = (char *)pkg_realloc(p, size * sizeof(char));
 		if (!np)
 		{
 			LM_ERR("Can't allocate memory (%lu bytes), pkg_realloc() has failed:"
-					" Not enough memory.\n", (unsigned long)size * sizeof(char *));
+					" Not enough memory.\n", (unsigned long)size * sizeof(char));
 			if (p)
 				pkg_free(p);
 			return NULL;




More information about the sr-dev mailing list