Skip to content

Commit 5961e1b

Browse files
committed
ext/xsl: free libxslt buffer when transformToXml output is empty
If xsltSaveResultToString sets doc_txt_ptr to a non-NULL allocation but doc_txt_len to zero, the previous gate skipped xmlFree and leaked the buffer. Current libxslt (1.1.34) sets both to NULL/0 in that case, so this is latent today; the fix removes the dependency on that convention.
1 parent 171b722 commit 5961e1b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ext/xsl/xsltprocessor.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,10 @@ PHP_METHOD(XSLTProcessor, transformToXml)
547547
ret = -1;
548548
if (newdocp) {
549549
ret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, newdocp, sheetp);
550-
if (doc_txt_ptr && doc_txt_len) {
551-
RETVAL_STRINGL((char *) doc_txt_ptr, doc_txt_len);
550+
if (doc_txt_ptr) {
551+
if (doc_txt_len > 0) {
552+
RETVAL_STRINGL((char *) doc_txt_ptr, doc_txt_len);
553+
}
552554
xmlFree(doc_txt_ptr);
553555
}
554556
xmlFreeDoc(newdocp);

0 commit comments

Comments
 (0)