hs: remove redundant file handle in HSLoadCache

HSLoadCache opened the cache file but never used the resulting handle
for reading. The actual read was done by HSReadStream which opened
the same file independently.

Removed the unused fopen/fclose pair and flattened the control flow.

Ticket: 8325
pull/14908/head
Lukas Sismis 6 months ago committed by Victor Julien
parent 569ba3d26f
commit d754b28717

@ -133,15 +133,12 @@ int HSLoadCache(hs_database_t **hs_db, const char *hs_db_hash, const char *dirpa
if (!SCPathExists(hash_file_static))
return -1;
FILE *db_cache = fopen(hash_file_static, "r");
char *buffer = NULL;
if (db_cache) {
size_t buffer_size;
buffer = HSReadStream(hash_file_static, &buffer_size);
if (!buffer) {
SCLogWarning("Hyperscan cached DB file %s cannot be read", hash_file_static);
ret = -1;
goto freeup;
return -1;
}
hs_error_t error = hs_deserialize_database(buffer, buffer_size, hs_db);
@ -157,13 +154,8 @@ int HSLoadCache(hs_database_t **hs_db, const char *hs_db_hash, const char *dirpa
if (SCTouchFile(hash_file_static) != 0) {
SCLogDebug("Failed to update mtime for %s", hash_file_static);
}
goto freeup;
}
freeup:
if (db_cache)
fclose(db_cache);
if (buffer)
SCFree(buffer);
return ret;
}

Loading…
Cancel
Save