Use gdb::unique_xmalloc_ptr when calling tilde_expand
[deliverable/binutils-gdb.git] / gdb / source.c
index 5473103b3fd6ff4765d9759537aae2362c1f1552..769d9efd3b92f73ecabe74b4763c3388c3729e10 100644 (file)
@@ -855,20 +855,18 @@ openp (const char *path, int opts, const char *string,
        {
         /* See whether we need to expand the tilde.  */
          int newlen;
-         char *tilde_expanded;
 
-         tilde_expanded  = tilde_expand (dir);
+         gdb::unique_xmalloc_ptr<char> tilde_expanded (tilde_expand (dir));
 
          /* First, realloc the filename buffer if too short.  */
-         len = strlen (tilde_expanded);
+         len = strlen (tilde_expanded.get ());
          newlen = len + strlen (string) + 2;
          if (newlen > alloclen)
            {
              alloclen = newlen;
              filename = (char *) alloca (alloclen);
            }
-         strcpy (filename, tilde_expanded);
-         xfree (tilde_expanded);
+         strcpy (filename, tilde_expanded.get ());
        }
       else
        {
This page took 0.030034 seconds and 4 git commands to generate.