+2015-07-10  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * tui/tui-win.c (tui_set_win_height): Use a cleanup to free the
+       string copy.
+       (parse_scrolling_args): Likewise.
+
 2015-07-10  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * tui/tui-win.c (focus_completer): Don't duplicate the tui window
 
       char *wname = (char *) NULL;
       int new_height, i;
       struct tui_win_info *win_info;
+      struct cleanup *old_chain;
 
+      old_chain = make_cleanup (xfree, buf);
       wname = buf_ptr;
       buf_ptr = strchr (buf_ptr, ' ');
       if (buf_ptr != (char *) NULL)
       else
        printf_filtered (WIN_HEIGHT_USAGE);
 
-      if (buf != (char *) NULL)
-       xfree (buf);
+      do_cleanups (old_chain);
     }
   else
     printf_filtered (WIN_HEIGHT_USAGE);
   if (arg != (char *) NULL)
     {
       char *buf, *buf_ptr;
+      struct cleanup *old_chain;
 
       /* Process the number of lines to scroll.  */
       buf = buf_ptr = xstrdup (arg);
+      old_chain = make_cleanup (xfree, buf);
       if (isdigit (*buf_ptr))
        {
          char *num_str;
          else if (*win_to_scroll == TUI_CMD_WIN)
            *win_to_scroll = (tui_source_windows ())->list[0];
        }
-      xfree (buf);
+      do_cleanups (old_chain);
     }
 }