Add asserts to ensure hostId > 0.
hostId is 1-based (e.g. pg1-*) so it should always be > 0.
@@ -95,6 +95,8 @@ pgIsLocal(unsigned int hostId)
FUNCTION_LOG_PARAM(UINT, hostId);
FUNCTION_LOG_END();
+ ASSERT(hostId > 0);
+
FUNCTION_LOG_RETURN(BOOL, !cfgOptionTest(cfgOptPgHost + hostId - 1));
}
@@ -110,6 +112,8 @@ protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int hostId,
FUNCTION_LOG_PARAM(UINT, protocolId);
FUNCTION_LOG_END();
+ ASSERT(hostId > 0);
+
StringList *result = NULL;
MEM_CONTEXT_TEMP_BEGIN()
@@ -156,6 +160,8 @@ protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int hostId, u
FUNCTION_LOG_PARAM(UINT, protocolId);
FUNCTION_LOG_END();
+ ASSERT(hostId > 0);
+
protocolHelperInit();
// Allocate the client cache
@@ -323,6 +329,8 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostId)
FUNCTION_LOG_PARAM(UINT, hostId);
FUNCTION_LOG_END();
+ ASSERT(hostId > 0);
+
// Is this a repo remote?
bool isRepo = protocolStorageType == protocolStorageTypeRepo;
