From 2fa76553709550c1eab8fe28423c26f725a32ba8 Mon Sep 17 00:00:00 2001 From: s1lent Date: Sun, 6 May 2018 13:33:38 +0700 Subject: [PATCH] Bugfix Info_ValueForKey: Fix wrong comparison --- rehlds/common/port.h | 2 +- rehlds/engine/info.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rehlds/common/port.h b/rehlds/common/port.h index 835ca2b..fc12e70 100644 --- a/rehlds/common/port.h +++ b/rehlds/common/port.h @@ -105,7 +105,7 @@ extern char g_szEXEName[ 4096 ]; #define _snprintf snprintf - + #if defined(OSX) #define SO_ARCH_SUFFIX ".dylib" #else diff --git a/rehlds/engine/info.cpp b/rehlds/engine/info.cpp index 0bd1cbd..82791d1 100644 --- a/rehlds/engine/info.cpp +++ b/rehlds/engine/info.cpp @@ -73,6 +73,7 @@ const char* EXT_FUNC Info_ValueForKey(const char *s, const char *lookup) static char valueBuf[INFO_MAX_BUFFER_VALUES][MAX_KV_LEN]; static int valueIndex; + size_t lookupLen = Q_strlen(lookup); while (*s == '\\') { // skip starting slash @@ -87,7 +88,6 @@ const char* EXT_FUNC Info_ValueForKey(const char *s, const char *lookup) s++; } - size_t keyLen = s - key; const char* value = ++s; // skip separating slash // skip value @@ -96,7 +96,7 @@ const char* EXT_FUNC Info_ValueForKey(const char *s, const char *lookup) size_t valueLen = Q_min(s - value, MAX_KV_LEN - 1); - if (!Q_strncmp(key, lookup, keyLen)) + if (!Q_strncmp(key, lookup, lookupLen)) { char* dest = valueBuf[valueIndex]; Q_memcpy(dest, value, valueLen); @@ -865,7 +865,7 @@ qboolean Info_IsValid(const char *s) // key should end with a '\', not a NULL if (*s == '\0') return FALSE; - + // quotes are deprecated if (*s == '"') return FALSE;