diff --git a/libxslt/transform.c b/libxslt/transform.c
index ae81d12dcb70bda156e4051f9e13a6a547571b76_bGlieHNsdC90cmFuc2Zvcm0uYw==..cf4eff2f9ec783e06ad8d265c2bcaf631160fa19_bGlieHNsdC90cmFuc2Zvcm0uYw== 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -3631,5 +3631,6 @@
     if (elements != NULL) {
 	if (style->stripSpaces == NULL)
 	    style->stripSpaces = xmlHashCreate(10);
-	if (style->stripSpaces == NULL)
+	if (style->stripSpaces == NULL) {
+	    xmlFree(elements);
 	    return;
@@ -3635,4 +3636,5 @@
 	    return;
+	}
 
 	element = elements;
 	while (*element != 0) {