From 934ad06cf146969d0ab40a4da7b7717dd0574dc6 Mon Sep 17 00:00:00 2001 From: Murai Takashi Date: Tue, 28 Jan 2020 20:46:23 +0900 Subject: [PATCH] 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 --- src/add-ons/kernel/file_systems/reiserfs/DirItem.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/file_systems/reiserfs/DirItem.h b/src/add-ons/kernel/file_systems/reiserfs/DirItem.h index b7e04ea952..e6d8f79c5b 100644 --- a/src/add-ons/kernel/file_systems/reiserfs/DirItem.h +++ b/src/add-ons/kernel/file_systems/reiserfs/DirItem.h @@ -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; } }