mirror of
https://github.com/henrypp/simplewall.git
synced 2026-10-23 19:42:27 -05:00
fixed map cleanup npe
This commit is contained in:
4 files changed
+18
-45
No files matched your search
+13
-14
@@ -127,7 +127,7 @@ bool _app_formataddress (ADDRESS_FAMILY af, UINT8 proto, const PVOID ptr_addr, U
|
||||
_r_str_cat (formatted_address, _countof (formatted_address), _r_fmt (L" (%s)", ptr_cache));
|
||||
|
||||
_r_fastlock_acquireexclusive (&lock_cache);
|
||||
_app_freeobjects_map (cache_hosts, false);
|
||||
_app_freeobjects_map (cache_hosts, UMAP_CACHE_LIMIT);
|
||||
_r_fastlock_releaseexclusive (&lock_cache);
|
||||
|
||||
cache_hosts[addr_hash] = _r_obj_allocate (ptr_cache, &_app_dereferencestring);
|
||||
@@ -163,20 +163,19 @@ rstring _app_formatport (UINT16 port, bool is_noempty)
|
||||
return result;
|
||||
}
|
||||
|
||||
void _app_freeobjects_map (OBJECTS_MAP& ptr_map, bool is_forced)
|
||||
void _app_freeobjects_map (OBJECTS_MAP& ptr_map, size_t max_size)
|
||||
{
|
||||
if (is_forced || ptr_map.size () >= UMAP_CACHE_LIMIT)
|
||||
for (auto &it = ptr_map.end (); it-- != ptr_map.begin ();)
|
||||
{
|
||||
for (auto &it = ptr_map.end (); it-- != ptr_map.begin ();)
|
||||
{
|
||||
PR_OBJECT ptr_object = _r_obj_reference (it->second);
|
||||
if (max_size && max_size >= ptr_map.size ())
|
||||
break;
|
||||
|
||||
if (ptr_object)
|
||||
_r_obj_dereferenceex (ptr_object, 2);
|
||||
PR_OBJECT ptr_object = _r_obj_reference (it->second);
|
||||
|
||||
ptr_map.erase (it);
|
||||
if (ptr_object)
|
||||
_r_obj_dereferenceex (ptr_object, 2);
|
||||
|
||||
}
|
||||
ptr_map.erase (it->first);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +410,7 @@ PR_OBJECT _app_getsignatureinfo (size_t app_hash, const PITEM_APP ptr_app)
|
||||
if (CertGetNameString (psProvCert->pCert, CERT_NAME_ATTR_TYPE, 0, szOID_COMMON_NAME, ptr_cache, num_chars) > 1)
|
||||
{
|
||||
_r_fastlock_acquireexclusive (&lock_cache);
|
||||
_app_freeobjects_map (cache_signatures, false);
|
||||
_app_freeobjects_map (cache_signatures, UMAP_CACHE_LIMIT);
|
||||
_r_fastlock_releaseexclusive (&lock_cache);
|
||||
|
||||
cache_signatures[app_hash] = _r_obj_allocate (ptr_cache, &_app_dereferencestring);
|
||||
@@ -533,7 +532,7 @@ PR_OBJECT _app_getversioninfo (size_t app_hash, const PITEM_APP ptr_app)
|
||||
if (_r_str_alloc (&ptr_cache, buffer.GetLength (), buffer))
|
||||
{
|
||||
_r_fastlock_acquireexclusive (&lock_cache);
|
||||
_app_freeobjects_map (cache_versions, false);
|
||||
_app_freeobjects_map (cache_versions, UMAP_CACHE_LIMIT);
|
||||
_r_fastlock_releaseexclusive (&lock_cache);
|
||||
|
||||
cache_versions[app_hash] = _r_obj_allocate (ptr_cache, &_app_dereferencestring);
|
||||
@@ -2465,7 +2464,7 @@ bool _app_parsenetworkstring (LPCWSTR network_string, NET_ADDRESS_FORMAT * forma
|
||||
if (_r_str_alloc (&ptr_cache, host.GetLength (), host))
|
||||
{
|
||||
_r_fastlock_acquireexclusive (&lock_cache);
|
||||
_app_freeobjects_map (cache_dns, false);
|
||||
_app_freeobjects_map (cache_dns, UMAP_CACHE_LIMIT);
|
||||
_r_fastlock_releaseexclusive (&lock_cache);
|
||||
|
||||
cache_dns[dns_hash] = _r_obj_allocate (ptr_cache, &_app_dereferencestring);
|
||||
@@ -2748,7 +2747,7 @@ bool _app_resolveaddress (ADDRESS_FAMILY af, LPVOID paddr, LPWSTR* pbuffer)
|
||||
if (_r_str_alloc (&ptr_cache, len, ppQueryResultsSet->Data.PTR.pNameHost))
|
||||
{
|
||||
_r_fastlock_acquireexclusive (&lock_cache);
|
||||
_app_freeobjects_map (cache_arpa, false);
|
||||
_app_freeobjects_map (cache_arpa, UMAP_CACHE_LIMIT);
|
||||
_r_fastlock_releaseexclusive (&lock_cache);
|
||||
|
||||
cache_arpa[arpa_hash] = _r_obj_allocate (ptr_cache, &_app_dereferencestring);
|
||||
|
||||
Reference in new issue
Block a user