Skip to content

Commit c5c66df

Browse files
committed
exslt: Fix EXSLT functions without parameters
Fix regression from commit 7364666 on platforms where malloc(0) returns NULL. Should fix #100.
1 parent 86ec392 commit c5c66df

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

libexslt/functions.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,15 @@ exsltFuncFunctionFunction (xmlXPathParserContextPtr ctxt, int nargs) {
385385
newBase = tctxt->varsNr;
386386
/* If there are any parameters */
387387
if (paramNode != NULL) {
388-
args = (xmlXPathObjectPtr *) xmlMalloc(sizeof(*args) * nargs);
389-
if (args == NULL)
390-
goto error;
391-
/* Fetch the stored argument values from the caller */
392-
for (i = nargs - 1; i >= 0; i--) {
393-
args[i] = valuePop(ctxt);
394-
}
388+
if (nargs > 0) {
389+
args = (xmlXPathObjectPtr *) xmlMalloc(sizeof(*args) * nargs);
390+
if (args == NULL)
391+
goto error;
392+
/* Fetch the stored argument values from the caller */
393+
for (i = nargs - 1; i >= 0; i--) {
394+
args[i] = valuePop(ctxt);
395+
}
396+
}
395397

396398
/*
397399
* Prepare to process params in reverse order. First, go to

0 commit comments

Comments
 (0)