diff -pdru ratpoison/src/actions.c ratpoison.build/src/actions.c --- ratpoison/src/actions.c 2013-08-07 12:08:11.154005173 -0300 +++ ratpoison.build/src/actions.c 2013-08-07 13:07:09.479860209 -0300 @@ -5515,6 +5515,7 @@ cmd_sfrestore (int interactively UNUSED, char *d; char *token; char *ptr; + char *tmp; struct sbuf *buffer[num_screens]; /* initialize frameset-buffer for each screen */ @@ -5543,12 +5544,17 @@ cmd_sfrestore (int interactively UNUSED, /* convert to integer */ x = strtol (ptr, NULL, 10); - /* check that specified screen number is not bigger than current number of connected screens */ - if (x < num_screens) { + /* check that specified screen number is not bigger than current number of + * connected screens and that the string is big enough */ + if (x < num_screens && strlen(token) > 2) { + /* copy token leaving out screen number at the end in order to pass it to + * frestore */ + tmp = strndup(token, strlen(token)-2); /* append frameset to buffer[x] */ - sbuf_concat(buffer[x], token); + sbuf_concat(buffer[x], tmp); sbuf_concat(buffer[x], ","); number_of_frames++; + free(tmp); } else { out_of_screen++;