From bec9ff8a40584431ef072fc2bc073cd8c8710e71 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 23 Nov 2017 01:15:44 +0100 Subject: [PATCH] loader: fix UB in try_load_file when loading file without known type --- panda/src/pgraph/loader.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index ae0bd7b01d..27b8404f04 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -277,7 +277,8 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, LoaderFileType *requested_type) const { BamCache *cache = BamCache::get_global_ptr(); - bool allow_ram_cache = requested_type->get_allow_ram_cache(options); + bool allow_ram_cache = + ((options.get_flags() & LoaderOptions::LF_no_ram_cache) == 0); if (allow_ram_cache) { // If we're allowing a RAM cache, use the ModelPool to load the file. @@ -298,7 +299,8 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, bool report_errors = ((options.get_flags() & LoaderOptions::LF_report_errors) != 0 || loader_cat.is_debug()); PT(BamCacheRecord) record; - if (cache->get_cache_models() && requested_type->get_allow_disk_cache(options)) { + if (cache->get_cache_models() && + (options.get_flags() & LoaderOptions::LF_no_disk_cache) == 0) { // See if the model can be found in the on-disk cache, if it is active. record = cache->lookup(pathname, "bam"); if (record != (BamCacheRecord *)NULL) {