Use short-circuit evaluation to avoid out-of-bounds string access. Thanks Jérôme!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41090 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user