From c2556eb90a83185e32f801163281eb8f30ea1b40 Mon Sep 17 00:00:00 2001 From: mini73 <@> Date: Sat, 11 Oct 2014 16:56:24 +0200 Subject: [PATCH] Fix bug: random rubbish at the end of letter. --- ChangeLog | 7 ++++++- video.c | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23650d9..466406d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ +User mini73 +Date: Sat Oct 11 16:53:18 CEST 2014 + + Fix bug: random rubbish at the end of letter. + User johns -Date: +Date: Tue Sep 23 12:36:39 CEST 2014 Fix audio thread close race condition. Support ffmpeg new AVFrame API in the audio codec. diff --git a/video.c b/video.c index a5b3a5a..2fd63d7 100644 --- a/video.c +++ b/video.c @@ -9736,6 +9736,7 @@ static void VideoEvent(void) const char *keynam; char buf[64]; char letter[64]; + int letter_len; uint32_t values[1]; VideoThreadLock(); @@ -9775,8 +9776,14 @@ static void VideoEvent(void) break; case KeyPress: VideoThreadLock(); - XLookupString(&event.xkey, letter, sizeof(letter), &keysym, NULL); + letter_len = + XLookupString(&event.xkey, letter, sizeof(letter) - 1, &keysym, + NULL); VideoThreadUnlock(); + if (letter_len < 0) { + letter_len = 0; + } + letter[letter_len] = '\0'; if (keysym == NoSymbol) { Warning(_("video/event: No symbol for %d\n"), event.xkey.keycode);