]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Custom attribute definitions should use cfg_alloc(), not malloc()
authorOndrej Zajicek <santiago@crfreenet.org>
Wed, 4 Oct 2023 17:45:00 +0000 (19:45 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Wed, 4 Oct 2023 18:16:13 +0000 (20:16 +0200)
Otherwise we would get memory leaks.

proto/bgp/config.Y

index e7a2f5cb0630bfb08eaa2dcaefabb2dc1dda0147..4e7d0329d3eba8d312edf6539297365b41115e75 100644 (file)
@@ -369,8 +369,8 @@ custom_attr: ATTRIBUTE BGP NUM type symbol ';' {
   if($3 > 255 || $3 < 1)
     cf_error("Invalid attribute number. (Given %i, must be 1-255.)", $3);
   if($4 != T_BYTESTRING)
-    cf_error("Attribute type must be bytestring, not %s.", f_type_name($4));
-  struct f_dynamic_attr* a = (struct f_dynamic_attr*) malloc(sizeof(struct f_dynamic_attr));
+    cf_error("Attribute type must be bytestring, not %s", f_type_name($4));
+  struct f_dynamic_attr *a = cfg_alloc(sizeof(struct f_dynamic_attr));
   *a = f_new_dynamic_attr(f_type_attr($4), T_BYTESTRING, EA_CODE(PROTOCOL_BGP, $3));
   a->flags = BAF_TRANSITIVE | BAF_OPTIONAL;
   cf_define_symbol(new_config, $5, SYM_ATTRIBUTE, attribute, a);