diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 3d92b1d674570561d23c03e64491f20946f266d4..bd2242c85620ec646ecb47e11dcde61fac56f789 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2160,10 +2160,10 @@ class Form
                     $form.= $opt;
                     $i++;
                 }
-                $form.= '</select>';
-
-                $this->db->free($result);
             }
+
+            $form.= '</select>';
+            $this->db->free($result);
             return $form;
         }
         else