Fix a potential null deref when rebuilding md cache

Issue discovered using clang's static analyzer
This commit is contained in:
Sebastian Hahn 2011-04-26 04:23:35 +02:00 committed by Nick Mathewson
parent 8ebb3ce6e2
commit 1827e60976
2 changed files with 6 additions and 1 deletions

5
changes/mdesc_null_deref Normal file
View File

@ -0,0 +1,5 @@
o Minor bugfixes:
- Avoid a possible null-pointer dereference when rebuilding the mdesc
cache without actually having any descriptors to cache. Bugfix on
0.2.2.6-alpha. Issue discovered using clang's static analyzer.

View File

@ -423,7 +423,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
cache->journal_len = 0;
cache->bytes_dropped = 0;
new_size = (int)cache->cache_content->size;
new_size = cache->cache_content ? (int)cache->cache_content->size : 0;
log_info(LD_DIR, "Done rebuilding microdesc cache. "
"Saved %d bytes; %d still used.",
orig_size-new_size, new_size);