diff options
author | Andrés <andmarti@gmail.com> | 2021-06-11 10:28:38 -0300 |
---|---|---|
committer | Andrés <andmarti@gmail.com> | 2021-06-11 10:28:38 -0300 |
commit | ab0ff4f020b4a65082cddb7cc218bef17ca12c54 (patch) | |
tree | 0237b9d52a9fa804a050eb08080277a7fea73968 /src | |
parent | 77d0316bfd9b28bcc0baef4d2d3148080285681b (diff) |
Check string length when pasting from clipboard
Diffstat (limited to 'src')
-rw-r--r-- | src/clipboard.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/clipboard.c b/src/clipboard.c index 534795a..5d04a8a 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -104,11 +104,17 @@ int paste_from_clipboard() { char * st = token; if (strlen(num) && isnumeric(num)) swprintf(line_interp, BUFFERSIZE, L"let %s%d=%s", coltoa(c), r, num); - else + else { + if (strlen(st) > MAX_IB_LEN) { + sc_debug("Content from clipboard exceeds maximum width for a label. Cutting it to %d chars", MAX_IB_LEN); + st[MAX_IB_LEN-1]='\0'; + } swprintf(line_interp, BUFFERSIZE, L"label %s%d=\"%s\"", coltoa(c), r, st); + } if (strlen(st)) send_to_interp(line_interp); c++; token = xstrtok(NULL, delim); + free(num); //free(st); if (c > roman->cur_sh->maxcol) roman->cur_sh->maxcol = c; } |