Index: /trunk/fastxsl.c =================================================================== --- /trunk/fastxsl.c (revision 26) +++ /trunk/fastxsl.c (revision 29) @@ -355,5 +355,4 @@ xmlXPathObjectPtr idoc, obj; int lockfd; - int popped = 0; char *ss_filename; int ss_filename_len; @@ -412,14 +411,14 @@ ss_wrapper->data_type = FASTXSL_STYLESHEET; func = xmlXPathFunctionLookup(ctxt->context, (const xmlChar *)"document"); + valuePush(ctxt, xmlXPathObjectCopy(ctxt->value)); + func(ctxt, nargs); ShmCache_UseAllocationFunctions(); inshm = 1; FASTXSL_G(tmp_allocated_size) = 0; - func(ctxt, nargs); - ss_wrapper->data.op = ctxt->value; + ss_wrapper->data.op = xmlXPathObjectCopy(ctxt->value); ss_wrapper->allocsize = FASTXSL_G(tmp_allocated_size); - valuePop(ctxt); - popped = 1; inshm = 0; Xml_UseAllocationFunctions(); + valuePop(ctxt); ss_wrapper->mtime = sb.st_mtime; mm_lock(FASTXSL_G(cache)->mm, MM_LOCK_RD); @@ -470,13 +469,13 @@ ss_wrapper->data_type = FASTXSL_STYLESHEET; func = xmlXPathFunctionLookup(ctxt->context, (const xmlChar *)"document"); + valuePush(ctxt, xmlXPathObjectCopy(ctxt->value)); + func(ctxt, nargs); ShmCache_UseAllocationFunctions(); inshm = 1; FASTXSL_G(tmp_allocated_size) = 0; - func(ctxt, nargs); - ss_wrapper->data.op = ctxt->value; - valuePop(ctxt); - popped = 1; + ss_wrapper->data.op = xmlXPathObjectCopy(ctxt->value); inshm = 0; Xml_UseAllocationFunctions(); + valuePop(ctxt); ss_wrapper->mtime = sb.st_mtime; ss_wrapper->allocsize = FASTXSL_G(tmp_allocated_size); @@ -527,5 +526,5 @@ close(lockfd); - if(!popped) valuePop(ctxt); + valuePop(ctxt); valuePush(ctxt, xmlXPathObjectCopy(ss_wrapper->data.op)); return; @@ -771,5 +770,5 @@ } - *parameters = calloc(1, (zend_hash_num_elements(h_parameters) * (2 * sizeof(char *))) + 1); + *parameters = calloc(1, (1 + zend_hash_num_elements(h_parameters) * 2) * sizeof(char *)); if (!*parameters) { php_error(E_WARNING, "Cannot allocate parameters array to pass to FastXSL");