From 403b4f89bd83ccbfe130ba97f30b8ea4718da562 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 31 Mar 2006 06:16:20 +0000 Subject: [PATCH] =?UTF-8?q?Date:=20Wed,=2029=20Mar=202006=2017:26:55=20+02?= =?UTF-8?q?00=20CEST=20From:=20"Fran=EF=BF=BD=EF=BF=BD=EF=BF=BDis=20Revol"?= =?UTF-8?q?=20Subject:=20[SDL]=20BeOS=20port=20fix:=20PrintScreen=20key=20?= =?UTF-8?q?crashing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems the latest SDL crashes when someone hits the PrtScrn key in ZETA (BeOS R6), somewhere it gets a negative value as key code (or a big unsigned maybe ?), and uses it as an index in the keysym table... I'll investigate the cause for the negative value, but it's always better to check for bounds correctly when indexing a table. The attached diff fixes it. Fran���is Revol -- Software Architect yellowTAB GmbH --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401621 --- src/video/bwindow/SDL_BWin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index 010eb31ff..a6d3ef8d9 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -478,7 +478,7 @@ public: if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) { SDL_keysym keysym; keysym.scancode = key; - if (key < 128) { + if ((key > 0) && (key < 128)) { keysym.sym = keymap[key]; } else { keysym.sym = SDLK_UNKNOWN; @@ -511,7 +511,7 @@ public: if (msg->FindInt32("key", &key) == B_OK && msg->FindInt32("modifiers", &modifiers) == B_OK) { SDL_keysym keysym; keysym.scancode = key; - if (key < 128) { + if ((key > 0) && (key < 128)) { keysym.sym = keymap[key]; } else { keysym.sym = SDLK_UNKNOWN;