]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use local boolean.
authorAlan T. DeKok <aland@freeradius.org>
Sat, 18 Sep 2021 13:19:06 +0000 (09:19 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 18 Sep 2021 13:20:00 +0000 (09:20 -0400)
by the time we get to checking if attr<0, it's already been updated
and allocated.

src/lib/util/dict_util.c

index aefa3aa607a386aed51c7095ec2e79c66f1d7a1f..e5c9e65c580f3e34913d132a841d749f167e786c 100644 (file)
@@ -1138,12 +1138,15 @@ int fr_dict_attr_add(fr_dict_t *dict, fr_dict_attr_t const *parent,
        fr_dict_attr_t          *n;
        fr_dict_attr_t const    *old;
        fr_dict_attr_flags_t    our_flags = *flags;
+       bool                    self_allocated = false;
 
        if (unlikely(dict->read_only)) {
                fr_strerror_printf("%s dictionary has been marked as read only", fr_dict_root(dict)->name);
                return -1;
        }
 
+       self_allocated = (attr < 0);
+
        /*
         *      Check that the definition is valid.
         */
@@ -1161,7 +1164,7 @@ int fr_dict_attr_add(fr_dict_t *dict, fr_dict_attr_t const *parent,
                 */
                if ((old->parent == parent) && (old->type == type) &&
                    FLAGS_EQUAL(array) && FLAGS_EQUAL(subtype)  &&
-                   ((old->attr == (unsigned int) attr) || ((attr < 0) && old->flags.internal))) {
+                   ((old->attr == (unsigned int) attr) || self_allocated)) {
                        return 0;
                }