From 8a7822cf24ed6f4cce3cd6a09e33e37249180585 Mon Sep 17 00:00:00 2001 From: Corne' Cornelius Date: Thu, 27 Feb 2003 08:56:15 +0000 Subject: - Fixed possible Segfault in ifx_errormsg() using malloc() instead of emalloc() --- ext/informix/ifx.ec | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ext/informix/ifx.ec b/ext/informix/ifx.ec index 162806432a..96572d5612 100644 --- a/ext/informix/ifx.ec +++ b/ext/informix/ifx.ec @@ -1650,15 +1650,14 @@ PHP_FUNCTION(ifx_errormsg) break; } - maxmsglen = 255; + maxmsglen = 10; msglen = maxmsglen; /* Some bug fix, rgetlmsg doesnt always set the value */ - ifx_errmsg = (char *)malloc(maxmsglen + 1); + ifx_errmsg = (char *)emalloc(maxmsglen + 1); if (ifx_errorcode != 0) { rgetlmsg(ifx_errorcode, ifx_errmsg, maxmsglen, &msglen); if (msglen > maxmsglen) { - maxmsglen = msglen + 1; - free(ifx_errmsg); - ifx_errmsg = (char *)malloc(maxmsglen + 1); + maxmsglen = msglen; + ifx_errmsg = (char *)erealloc(ifx_errmsg, maxmsglen + 1); rgetlmsg(ifx_errorcode, ifx_errmsg, maxmsglen, &msglen); } } else { @@ -1667,7 +1666,7 @@ PHP_FUNCTION(ifx_errormsg) returnmsg = (char *) emalloc(strlen(ifx_errmsg) + 128); sprintf(returnmsg, ifx_errmsg, sqlca.sqlerrm); - free(ifx_errmsg); + efree(ifx_errmsg); RETURN_STRING(returnmsg,0); } /* }}} */ -- cgit v1.2.1