session: fix use-after-free
[vpp.git] / src / vnet / session / mma_template.c
index 9dd7c76..ae730e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
@@ -60,8 +60,8 @@ RTT (mma_rule) * RT (mma_rules_table_rule_alloc) (RTT (mma_rules_table) * srt)
 RTT (mma_rule) *
 RT (mma_rule_free) (RTT (mma_rules_table) * srt, RTT (mma_rule) * rule)
 {
-  pool_put (srt->rules, rule);
   clib_memset (rule, 0xfa, sizeof (*rule));
+  pool_put (srt->rules, rule);
   return rule;
 }