From 34e2524a83b0040a1d25cc0fa12e9f9cd03ba61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 19 Nov 2018 13:33:35 +0100 Subject: [PATCH] [ion] Storage: use strncmp instead of strcmp When building with -fsanitize=address, strcmp is wrapped in a version that returns only +1, -1 or 0. --- ion/src/shared/storage.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ion/src/shared/storage.cpp b/ion/src/shared/storage.cpp index 0cd79147e..c40e42184 100644 --- a/ion/src/shared/storage.cpp +++ b/ion/src/shared/storage.cpp @@ -203,9 +203,7 @@ Storage::Record Storage::recordBaseNamedWithExtensions(const char * baseName, co size_t nameLength = strlen(baseName); for (char * p : *this) { const char * currentName = fullNameOfRecordStarting(p); - /* To not add the method strncmp, we use strcmp and compare to the expected - * result. */ - if (strcmp(baseName, currentName) == 0 - currentName[nameLength]) { + if (strncmp(baseName, currentName, nameLength) == 0) { for (size_t i = 0; i < numberOfExtensions; i++) { if (strcmp(currentName+nameLength+1 /*+1 to pass the dot*/, extensions[i]) == 0) { return Record(currentName);