reiserfs: Fix PVS V595

Check 'name' pointer against NULL before using it.

Change-Id: I8b40ee28a12210d1989cc717ecb67d6e1c0a1544
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2205
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Murai Takashi 2020-01-28 20:46:23 +09:00 committed by waddlesplash
parent 7eaa780a81
commit 934ad06cf1

View File

@ -142,12 +142,15 @@ public:
int32 IndexOfName(const char *name) const
{
if (name == NULL)
return -1;
int32 count = GetEntryCount();
size_t len = strlen(name);
for (int32 i = 0; i < count; i++) {
size_t nameLen = 0;
const char *itemName = EntryNameAt(i, &nameLen);
if (name && nameLen == len && !strncmp(name, itemName, len)) {
if (nameLen == len && !strncmp(name, itemName, len)) {
return i;
}
}