mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Fix nvault issues.
This includes an original one leading to a crash at mapchange if empty key or value are saved.
This commit is contained in:
parent
3dace577fe
commit
1ae40316a8
@ -102,14 +102,14 @@ VaultError NVault::_ReadFromFile()
|
|||||||
if (!br.ReadUInt8(keylen)) goto fail;
|
if (!br.ReadUInt8(keylen)) goto fail;
|
||||||
if (!br.ReadUInt16(vallen)) goto fail;
|
if (!br.ReadUInt16(vallen)) goto fail;
|
||||||
|
|
||||||
if (keylen > oldkeylen)
|
if (!keylen || keylen > oldkeylen)
|
||||||
{
|
{
|
||||||
if (key)
|
if (key)
|
||||||
delete [] key;
|
delete [] key;
|
||||||
key = new char[keylen + 1];
|
key = new char[keylen + 1];
|
||||||
oldkeylen = keylen;
|
oldkeylen = keylen;
|
||||||
}
|
}
|
||||||
if (vallen > oldvallen)
|
if (!vallen || vallen > oldvallen)
|
||||||
{
|
{
|
||||||
if (val)
|
if (val)
|
||||||
delete [] val;
|
delete [] val;
|
||||||
@ -209,13 +209,13 @@ success:
|
|||||||
|
|
||||||
const char *NVault::GetValue(const char *key)
|
const char *NVault::GetValue(const char *key)
|
||||||
{
|
{
|
||||||
ArrayInfo result;
|
StringHashMap<ArrayInfo>::Result r = m_Hash.find(key);
|
||||||
if (!m_Hash.retrieve(key, &result))
|
if (!r.found())
|
||||||
{
|
{
|
||||||
result.value.setVoid();
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.value.chars();
|
return r->value.value.chars();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NVault::Open()
|
bool NVault::Open()
|
||||||
@ -350,10 +350,7 @@ void NVault::Touch(const char *key, time_t stamp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayInfo info; info.value = ""; info.stamp = time(NULL);
|
SetValue(key, "", time(NULL));
|
||||||
|
|
||||||
i->key = key;
|
|
||||||
i->value = info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i->value.stamp = stamp;
|
i->value.stamp = stamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user