--- transform_org.c	2015-11-06 11:19:41.876081548 +0530
+++ transform.c	2015-11-06 11:51:55.728131191 +0530
@@ -834,6 +834,12 @@
     if (copy != NULL) {
 	if (target != NULL)
 	    copy = xsltAddChild(target, copy);
+        if (copy == NULL) {
+            xsltTransformError(ctxt, NULL, target,
+                         "xsltCopyTextString: text copy failed\n");
+            ctxt->lasttext = NULL;
+            return (copy);
+        }       
 	ctxt->lasttext = copy->content;
 	ctxt->lasttsize = len;
 	ctxt->lasttuse = len;
@@ -1222,6 +1228,11 @@
     if (copy != NULL) {
 	copy->doc = ctxt->output;
 	copy = xsltAddChild(insert, copy);
+        if (copy == NULL) {
+             xsltTransformError(ctxt, NULL, node,
+                "xsltShallowCopyElem: copy failed\n");
+             return (copy);
+        }
 
 	if (node->type == XML_ELEMENT_NODE) {
 	    /*
@@ -1555,6 +1566,11 @@
     if (copy != NULL) {
 	copy->doc = ctxt->output;
 	copy = xsltAddChild(insert, copy);
+        if (copy == NULL) {
+            xsltTransformError(ctxt, NULL, invocNode,
+            "xsltCopyTreeInternal: Copying of '%s' failed.\n", node->name);
+            return (copy);
+        }
 	/*
 	 * The node may have been coalesced into another text node.
 	 */
@@ -4034,7 +4050,12 @@
 	return;
     }
     copy = xsltAddChild(ctxt->insert, copy);
-
+    if (copy == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+            "xsl:element : xsltAddChild failed\n");
+        return;
+    }
+       
     /*
     * Namespace
     * ---------
