diff options
| author | Paul Eggert | 2014-02-28 13:45:34 -0800 |
|---|---|---|
| committer | Paul Eggert | 2014-02-28 13:45:34 -0800 |
| commit | 8268febfe0c336ff47a61d0d416fd4bebf61a993 (patch) | |
| tree | 4a1590e6aff922e69646cc35347192ea507b1c7a /src/term.c | |
| parent | b70257b07ea6053bce27b20ad0bda50f547bd393 (diff) | |
| download | emacs-8268febfe0c336ff47a61d0d416fd4bebf61a993.tar.gz emacs-8268febfe0c336ff47a61d0d416fd4bebf61a993.zip | |
Fix a few crashes and leaks when cloning C strings.
* alloc.c, lisp.h (dupstring): New function.
* gtkutil.c (xg_get_font):
* term.c (tty_default_color_capabilities):
* xsettings.c (store_monospaced_changed)
(store_font_name_changed, parse_settings)
(read_and_apply_settings, init_gsettings, init_gconf): Use it.
This avoids some unlikely crashes due to accessing freed storage,
and avoids some minor memory leaks in the more-typical case.
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/term.c b/src/term.c index 0c40c2d16b9..61a8d39d971 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2052,17 +2052,9 @@ tty_default_color_capabilities (struct tty_display_info *tty, bool save) | |||
| 2052 | 2052 | ||
| 2053 | if (save) | 2053 | if (save) |
| 2054 | { | 2054 | { |
| 2055 | xfree (default_orig_pair); | 2055 | dupstring (&default_orig_pair, tty->TS_orig_pair); |
| 2056 | default_orig_pair = tty->TS_orig_pair ? xstrdup (tty->TS_orig_pair) : NULL; | 2056 | dupstring (&default_set_foreground, tty->TS_set_foreground); |
| 2057 | 2057 | dupstring (&default_set_background, tty->TS_set_background); | |
| 2058 | xfree (default_set_foreground); | ||
| 2059 | default_set_foreground = tty->TS_set_foreground ? xstrdup (tty->TS_set_foreground) | ||
| 2060 | : NULL; | ||
| 2061 | |||
| 2062 | xfree (default_set_background); | ||
| 2063 | default_set_background = tty->TS_set_background ? xstrdup (tty->TS_set_background) | ||
| 2064 | : NULL; | ||
| 2065 | |||
| 2066 | default_max_colors = tty->TN_max_colors; | 2058 | default_max_colors = tty->TN_max_colors; |
| 2067 | default_max_pairs = tty->TN_max_pairs; | 2059 | default_max_pairs = tty->TN_max_pairs; |
| 2068 | default_no_color_video = tty->TN_no_color_video; | 2060 | default_no_color_video = tty->TN_no_color_video; |