struct solib_catchpoint : public breakpoint
 {
-  ~solib_catchpoint () override;
-
   /* True for "catch load", false for "catch unload".  */
   bool is_load;
 
   /* Regular expression to match, if any.  COMPILED is only valid when
      REGEX is non-NULL.  */
-  char *regex;
+  gdb::unique_xmalloc_ptr<char> regex;
   std::unique_ptr<compiled_regex> compiled;
 };
 
-solib_catchpoint::~solib_catchpoint ()
-{
-  xfree (this->regex);
-}
-
 static int
 insert_catch_solib (struct bp_location *ignore)
 {
   if (self->is_load)
     {
       if (self->regex)
-       msg = string_printf (_("load of library matching %s"), self->regex);
+       msg = string_printf (_("load of library matching %s"),
+                            self->regex.get ());
       else
        msg = _("load of library");
     }
   else
     {
       if (self->regex)
-       msg = string_printf (_("unload of library matching %s"), self->regex);
+       msg = string_printf (_("unload of library matching %s"),
+                            self->regex.get ());
       else
        msg = _("unload of library");
     }
                      b->disposition == disp_del ? "tcatch" : "catch",
                      self->is_load ? "load" : "unload");
   if (self->regex)
-    fprintf_unfiltered (fp, " %s", self->regex);
+    fprintf_unfiltered (fp, " %s", self->regex.get ());
   fprintf_unfiltered (fp, "\n");
 }
 
     {
       c->compiled.reset (new compiled_regex (arg, REG_NOSUB,
                                             _("Invalid regexp")));
-      c->regex = xstrdup (arg);
+      c->regex = make_unique_xstrdup (arg);
     }
 
   c->is_load = is_load;