From af2589e943cb1797d0ecc7bd034a84d022ea46d0 Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Wed, 26 Feb 2003 17:38:03 +0000 Subject: [PATCH] MFphp5 --- ext/yp/yp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ext/yp/yp.c b/ext/yp/yp.c index 80ba55a82a..1edf277236 100644 --- a/ext/yp/yp.c +++ b/ext/yp/yp.c @@ -291,8 +291,17 @@ static int php_foreach_cat (int instatus, char *inkey, int inkeylen, char *inval if (!err) { - if (inkeylen) - add_assoc_stringl_ex((zval *) indata,inkey,inkeylen,inval,invallen,1); + if (inkeylen) { + char *key = emalloc(inkeylen+1); + if(key) { + strncpy(key, inkey, inkeylen); + key[inkeylen] = '\0'; + add_assoc_stringl_ex((zval *) indata, key, inkeylen+1, inval, invallen, 1); + efree(key); + } else { + php_error(E_WARNING, "Can't allocate %d bytes for key buffer in yp_cat()"); + } + } return 0; } -- 2.50.1