Skip to content

Commit 8a7822c

Browse files
author
Corne' Cornelius
committed
- Fixed possible Segfault in ifx_errormsg() using malloc() instead of emalloc()
1 parent 4fbdee3 commit 8a7822c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ext/informix/ifx.ec

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,15 +1650,14 @@ PHP_FUNCTION(ifx_errormsg)
16501650
break;
16511651
}
16521652

1653-
maxmsglen = 255;
1653+
maxmsglen = 10;
16541654
msglen = maxmsglen; /* Some bug fix, rgetlmsg doesnt always set the value */
1655-
ifx_errmsg = (char *)malloc(maxmsglen + 1);
1655+
ifx_errmsg = (char *)emalloc(maxmsglen + 1);
16561656
if (ifx_errorcode != 0) {
16571657
rgetlmsg(ifx_errorcode, ifx_errmsg, maxmsglen, &msglen);
16581658
if (msglen > maxmsglen) {
1659-
maxmsglen = msglen + 1;
1660-
free(ifx_errmsg);
1661-
ifx_errmsg = (char *)malloc(maxmsglen + 1);
1659+
maxmsglen = msglen;
1660+
ifx_errmsg = (char *)erealloc(ifx_errmsg, maxmsglen + 1);
16621661
rgetlmsg(ifx_errorcode, ifx_errmsg, maxmsglen, &msglen);
16631662
}
16641663
} else {
@@ -1667,7 +1666,7 @@ PHP_FUNCTION(ifx_errormsg)
16671666

16681667
returnmsg = (char *) emalloc(strlen(ifx_errmsg) + 128);
16691668
sprintf(returnmsg, ifx_errmsg, sqlca.sqlerrm);
1670-
free(ifx_errmsg);
1669+
efree(ifx_errmsg);
16711670
RETURN_STRING(returnmsg,0);
16721671
}
16731672
/* }}} */

0 commit comments

Comments
 (0)