diff --git a/libsqsh/src/extract/extract_manager.c b/libsqsh/src/extract/extract_manager.c index 5ad1fe8f..da4405cc 100644 --- a/libsqsh/src/extract/extract_manager.c +++ b/libsqsh/src/extract/extract_manager.c @@ -169,6 +169,7 @@ sqsh__extract_manager_uncompress( const struct CxBuffer **target) { int rv = 0; bool locked = false; + struct CxBuffer *buffer = NULL; rv = sqsh__mutex_lock(&manager->lock); if (rv < 0) { @@ -178,17 +179,17 @@ sqsh__extract_manager_uncompress( const uint64_t address = sqsh__map_reader_address(reader); - *target = cx_rc_radix_tree_retain(&manager->cache, address); + buffer = cx_rc_radix_tree_retain(&manager->cache, address); - if (*target == NULL) { - struct CxBuffer buffer = {0}; + if (buffer == NULL) { + struct CxBuffer tmp_buffer = {0}; rv = sqsh__mutex_unlock(&manager->lock); if (rv < 0) { goto out; } locked = false; - rv = extract(manager, reader, &buffer); + rv = extract(manager, reader, &tmp_buffer); if (rv < 0) { goto out; } @@ -199,9 +200,10 @@ sqsh__extract_manager_uncompress( } locked = true; - *target = cx_rc_radix_tree_put(&manager->cache, address, &buffer); + buffer = cx_rc_radix_tree_put(&manager->cache, address, &tmp_buffer); } - rv = cx_lru_touch(&manager->lru, address); + rv = cx_lru_touch_value(&manager->lru, address, buffer); + *target = buffer; out: if (locked) { diff --git a/subprojects/cextras.wrap b/subprojects/cextras.wrap index bf9ee494..0efc6a97 100644 --- a/subprojects/cextras.wrap +++ b/subprojects/cextras.wrap @@ -1,6 +1,6 @@ [wrap-git] directory = cextras -revision = 393f89745bb306855b3f8dab2c9b268e8feddbae +revision = b9d8c14575287ddcf87abcbf8889caf42574f253 url = https://github.com/Gottox/cextras.git depth = 1