]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/rbbinode.cpp
ICU-461.12.tar.gz
[apple/icu.git] / icuSources / common / rbbinode.cpp
index af467b6d0642e4cd1c2ec66acaee88a9da435591..49e0ad3dfa43a8e4bd367be7a0370a6059a084c7 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ***************************************************************************
-*   Copyright (C) 2002-2006 International Business Machines Corporation   *
+*   Copyright (C) 2002-2008 International Business Machines Corporation   *
 *   and others. All rights reserved.                                      *
 ***************************************************************************
 */
@@ -149,13 +149,16 @@ RBBINode *RBBINode::cloneTree() {
         n = this;
     } else {
         n = new RBBINode(*this);
-        if (fLeftChild != NULL) {
-            n->fLeftChild          = fLeftChild->cloneTree();
-            n->fLeftChild->fParent = n;
-        }
-        if (fRightChild != NULL) {
-            n->fRightChild          = fRightChild->cloneTree();
-            n->fRightChild->fParent = n;
+        // Check for null pointer.
+        if (n != NULL) {
+            if (fLeftChild != NULL) {
+                n->fLeftChild          = fLeftChild->cloneTree();
+                n->fLeftChild->fParent = n;
+            }
+            if (fRightChild != NULL) {
+                n->fRightChild          = fRightChild->cloneTree();
+                n->fRightChild->fParent = n;
+            }
         }
     }
     return n;