diff --git a/ChangeLog b/ChangeLog
index 264486a6436cdc693d49793feffc000038d5f946_Q2hhbmdlTG9n..99e8ac8decc6655d1e1cdee3ebcd5fb2d123d7cd_Q2hhbmdlTG9n 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jan  8 12:33:47 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+	* libxslt/transform.c: fixed a problem related to directory
+	  checking and creation raised by Craig Goss
+
 Thu Jan  2 23:23:30 CET 2003 Daniel Veillard <daniel@veillard.com>
 
 	* libexslt/strings.c: applied patch from J�rg Walter to provide
diff --git a/libxslt/transform.c b/libxslt/transform.c
index 264486a6436cdc693d49793feffc000038d5f946_bGlieHNsdC90cmFuc2Zvcm0uYw==..99e8ac8decc6655d1e1cdee3ebcd5fb2d123d7cd_bGlieHNsdC90cmFuc2Zvcm0uYw== 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -3802,6 +3802,20 @@
 	xmlFreeDoc(res);
 	res = NULL;
     }
+    if ((res != NULL) && (ctxt != NULL) && (output != NULL)) {
+	int ret;
+
+	ret = xsltCheckWrite(userCtxt->sec, userCtxt, output);
+	if (ret == 0) {
+	    xsltTransformError(ctxt, NULL, NULL,
+		     "xsltApplyStylesheet: forbidden to save to %s\n",
+			       output);
+	} else if (ret < 0) {
+	    xsltTransformError(ctxt, NULL, NULL,
+		     "xsltApplyStylesheet: saving to %s may not be possible\n",
+			       output);
+	}
+    }
 
     if ((ctxt != NULL) && (userCtxt == NULL))
 	xsltFreeTransformContext(ctxt);