]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
be more aggressive about freeing memory in cursors
authorAlan T. DeKok <aland@freeradius.org>
Thu, 26 Mar 2026 02:31:22 +0000 (15:31 +1300)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 26 Mar 2026 21:08:53 +0000 (10:08 +1300)
src/lib/server/tmpl_dcursor.c

index 5655dfee90f88b58d3de1d56a43c7468b8740a48..ed34dcf30f8eb1351392ad1a3d1fcf05b948dd3f 100644 (file)
@@ -422,6 +422,7 @@ fr_pair_t *tmpl_dcursor_init_relative(int *err, TALLOC_CTX *ctx, tmpl_dcursor_ct
                return NULL;
        }
 
+       if (err) *err = 0;
        return vp;
 }
 
@@ -529,15 +530,15 @@ fr_pair_t *tmpl_dcursor_value_box_init(int *err, TALLOC_CTX *ctx, fr_value_box_t
         */
        vp = tmpl_dcursor_init(err, cc, cc, cursor, request, vpt);
        if (!vp) {
-               if (!err) return NULL;
+               talloc_free(cc);
 
-               if (*err == -1) {
+               if (err && (*err == -1)) {
                        RWDEBUG("Cursor %s returned no attributes", vpt->name);
                        goto set_cursor;
-               } else {
-                       RPEDEBUG("Failed initializing cursor");
                }
 
+               RPEDEBUG("Failed initializing cursor");
+               talloc_free(cursor);
                return NULL;
        }
 
@@ -722,6 +723,7 @@ int tmpl_extents_find(TALLOC_CTX *ctx,
                break;
        }
 
+       tmpl_dcursor_clear(&cc);
        return 0;
 }