[Libreoffice-commits] core.git: configmgr/source

Stephan Bergmann sbergman at redhat.com
Tue Sep 1 02:33:43 PDT 2015


 configmgr/source/readdconflayer.cxx |  131 ++++++++++++++++++------------------
 1 file changed, 68 insertions(+), 63 deletions(-)

New commits:
commit df7fbad544679999c9635fc441571a0b52826d60
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Sep 1 11:32:50 2015 +0200

    readdconflayer: avoid deref of null (removed) member
    
    Change-Id: I3b2ce8ef79c4bc0dde8ba43f96ca4e97a71dd2cd

diff --git a/configmgr/source/readdconflayer.cxx b/configmgr/source/readdconflayer.cxx
index d6575e7..035f554 100644
--- a/configmgr/source/readdconflayer.cxx
+++ b/configmgr/source/readdconflayer.cxx
@@ -847,82 +847,87 @@ void readDir(
                     << node->getTemplateName());
             continue;
         }
-        if (member->getFinalized() < layer) {
-            continue;
-        }
-        switch (member->kind()) {
-        case Node::KIND_PROPERTY:
-            {
-                if (isDir) {
-                    SAL_WARN(
-                        "configmgr.dconf",
-                        "bad dir " << path << " does not match property");
-                    continue;
+        if (member.is()) {
+            if (member->getFinalized() < layer) {
+                continue;
+            }
+            switch (member->kind()) {
+            case Node::KIND_PROPERTY:
+                {
+                    if (isDir) {
+                        SAL_WARN(
+                            "configmgr.dconf",
+                            "bad dir " << path << " does not match property");
+                        continue;
+                    }
+                    rtl::Reference<PropertyNode> prop(
+                        static_cast<PropertyNode *>(member.get()));
+                    css::uno::Any value;
+                    switch (readValue(
+                                client, path, prop->getStaticType(),
+                                prop->isNillable(), prop->isExtension(),
+                                &value))
+                    {
+                    case ReadValue::Error:
+                        continue;
+                    case ReadValue::Value:
+                        prop->setValue(layer, value);
+                        finalize(client, path, member, layer);
+                        break;
+                    case ReadValue::Remove:
+                        remove = true;
+                        break;
+                    }
+                    break;
                 }
-                rtl::Reference<PropertyNode> prop(
-                    static_cast<PropertyNode *>(member.get()));
-                css::uno::Any value;
-                switch (readValue(
-                            client, path, prop->getStaticType(),
-                            prop->isNillable(), prop->isExtension(), &value))
+            case Node::KIND_LOCALIZED_VALUE:
                 {
-                case ReadValue::Error:
-                    continue;
-                case ReadValue::Value:
-                    prop->setValue(layer, value);
+                    if (isDir) {
+                        SAL_WARN(
+                            "configmgr.dconf",
+                            "bad dir " << path
+                                << " does not match localized value");
+                        continue;
+                    }
+                    assert(
+                        node.is()
+                        && node->kind() == Node::KIND_LOCALIZED_PROPERTY);
+                    rtl::Reference<LocalizedPropertyNode> locProp(
+                        static_cast<LocalizedPropertyNode *>(node.get()));
+                    css::uno::Any value;
+                    if (readValue(
+                            client, path, locProp->getStaticType(),
+                            locProp->isNillable(), false, &value)
+                        == ReadValue::Error)
+                    {
+                        continue;
+                    }
+                    static_cast<LocalizedValueNode *>(member.get())->setValue(
+                        layer, value);
                     finalize(client, path, member, layer);
                     break;
-                case ReadValue::Remove:
-                    remove = true;
-                    break;
                 }
-                break;
-            }
-        case Node::KIND_LOCALIZED_VALUE:
-            {
-                if (isDir) {
+            case Node::KIND_LOCALIZED_PROPERTY:
+            case Node::KIND_GROUP:
+            case Node::KIND_SET:
+                if (!isDir) {
                     SAL_WARN(
                         "configmgr.dconf",
-                        "bad dir " << path
-                            << " does not match localized value");
+                        "bad key " << path
+                            << " does not match localized property, group, or"
+                            " set, respectively");
                     continue;
                 }
-                assert(
-                    node.is() && node->kind() == Node::KIND_LOCALIZED_PROPERTY);
-                rtl::Reference<LocalizedPropertyNode> locProp(
-                    static_cast<LocalizedPropertyNode *>(node.get()));
-                css::uno::Any value;
-                if (readValue(
-                        client, path, locProp->getStaticType(),
-                        locProp->isNillable(), false, &value)
-                    == ReadValue::Error)
-                {
-                    continue;
-                }
-                static_cast<LocalizedValueNode *>(member.get())->setValue(
-                    layer, value);
-                finalize(client, path, member, layer);
+                assert(path.endsWith("/"));
+                readDir(
+                    data, layer, member, member->getMembers(), client, path);
                 break;
+            default:
+                assert(false); // cannot happen
             }
-        case Node::KIND_LOCALIZED_PROPERTY:
-        case Node::KIND_GROUP:
-        case Node::KIND_SET:
-            if (!isDir) {
-                SAL_WARN(
-                    "configmgr.dconf",
-                    "bad key " << path
-                        << " does not match localized property, group, or set,"
-                        " respectively");
-                continue;
-            }
-            assert(path.endsWith("/"));
-            readDir(data, layer, member, member->getMembers(), client, path);
-            break;
-        default:
-            assert(false); // cannot happen
         }
         if (remove) {
-            if (!member->getMandatory()) {
+            if (!(member.is() && member->getMandatory())) {
                 members.erase(name);
             }
         } else if (replace) {


More information about the Libreoffice-commits mailing list