--- libxslt-1.1.43/libxslt/security.c.orig	2025-03-12 18:57:19.000000000 +0100
+++ libxslt-1.1.43/libxslt/security.c	2025-07-20 09:34:53.152916900 +0200
@@ -10,6 +10,7 @@
 #include "libxslt.h"
 
 #include <string.h>
+#include <errno.h>
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -326,8 +327,16 @@
 		}
 	    }
 	    ret = xsltCheckWritePath(sec, ctxt, directory);
-	    if (ret == 1)
+	    if (ret == 1) {
 		ret = mkdir(directory, 0755);
+		if (ret == -1 && errno == EEXIST) {
+		    struct stat buf;
+                    ret = stat(directory, &buf);
+                    if (ret == 0) {
+                        ret = S_ISDIR(buf.st_mode) ? 0 : -1;
+                    }
+		}
+	    }
 	}
 	xmlFree(directory);
 	if (ret < 0)
