-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid null pointer dereference in dt_mipmap_cache_get_with_caller #18254
Avoid null pointer dereference in dt_mipmap_cache_get_with_caller #18254
Conversation
The pointer can be dereferenced (subject to certain conditions) elsewhere, too: if(flags == DT_MIPMAP_TESTLOCK)
{
// simple case: only get and lock if it's there.
dt_cache_entry_t *entry = dt_cache_testget(&_get_cache(cache, mip)->cache, key, mode);
buf->cache_entry = entry; else if(flags == DT_MIPMAP_BLOCKING)
{
// simple case: blocking get
dt_cache_entry_t *entry = dt_cache_get_with_caller(&_get_cache(cache, mip)->cache, key, mode, file, line);
ASAN_UNPOISON_MEMORY_REGION(entry->data, dt_mipmap_buffer_dsc_size);
struct dt_mipmap_buffer_dsc *dsc = (struct dt_mipmap_buffer_dsc *)entry->data;
buf->cache_entry = entry; else if(flags == DT_MIPMAP_BEST_EFFORT)
{
__sync_fetch_and_add(&(_get_cache(cache, mip)->stats_requests), 1);
// best-effort, might also return NULL.
// never decrease mip level for float buffer or full image:
dt_mipmap_size_t min_mip = (mip >= DT_MIPMAP_F) ? mip : DT_MIPMAP_0;
for(int k = mip; k >= min_mip && k >= 0; k--)
{
// already loaded?
dt_mipmap_cache_get(cache, buf, imgid, k, DT_MIPMAP_TESTLOCK, 'r');
if(buf->buf && buf->width > 0 && buf->height > 0) Also, should I update if(g_file_test(filename, G_FILE_TEST_EXISTS))
dt_mipmap_cache_get(cache, 0, imgid, DT_MIPMAP_0, DT_MIPMAP_PREFETCH_DISK, 0); to use NULL instead of 0 ( |
@jenshannoschwalm : I think it may make sense to merge this tiny change. In Line 1170 in 8fb4ae6
Line 1207 in 8fb4ae6
|
Full agreement from my side. |
e02c487
to
83efdea
Compare
Done, thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fully safe :) Thanks.
Guard against null pointer dereference when _thumbs_prefetch calls dt_mipmap_cache_get_with_caller with buf = NULL.
Fixes #18249.