From 2d5868f8b3681b7e5af8f96e10ec20b9462a71c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Wed, 23 Mar 2011 00:47:21 +0000 Subject: [PATCH] =?UTF-8?q?Use=20short-circuit=20evaluation=20to=20avoid?= =?UTF-8?q?=20out-of-bounds=20string=20access.=20Thanks=20J=C3=83=C2=A9r?= =?UTF-8?q?=C3=83=C2=B4me!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41090 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/ContainerWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index e7291eeed1..89a6688386 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -171,7 +171,7 @@ StripShortcut(const Model *model, char *result, uint32 &shortcut) // check if there is a shortcut in the model name uint32 length = strlen(result); - if (result[length - 2] == '-' && length > 2) { + if (length > 2 && result[length - 2] == '-') { shortcut = result[length - 1]; result[length - 2] = '\0'; return; @@ -180,7 +180,7 @@ StripShortcut(const Model *model, char *result, uint32 &shortcut) // check if there is a shortcut in the filename char* refName = model->EntryRef()->name; length = strlen(refName); - if (refName[length - 2] == '-' && length > 2) { + if (length > 2 && refName[length - 2] == '-') { shortcut = refName[length - 1]; return; }