[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.
This commit is contained in:
Émilie Feral
2018-11-19 13:33:35 +01:00
parent 584f6d6f6b
commit 34e2524a83

View File

@@ -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);