From c31edc6599f9159741981c7ef39b90c9eb9a7341 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sat, 22 Jan 2022 15:32:14 -0700 Subject: [PATCH] qbsp: FindMiptex: fix empty optional access when a .wal couldn't be found --- qbsp/map.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qbsp/map.cc b/qbsp/map.cc index c0cc749f..ded92db9 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -193,13 +193,15 @@ int FindMiptex(const char *name, std::optional &extended_inf if (!internal && !extended_info.has_value()) { wal = LoadWal(name); - if (!wal.has_value()) { - extended_info = extended_texinfo_t{}; - } else { + if (wal) { extended_info = extended_texinfo_t{wal->contents, wal->flags, wal->value}; } } + if (!extended_info.has_value()) { + extended_info = extended_texinfo_t{}; + } + for (i = 0; i < map.nummiptex(); i++) { const texdata_t &tex = map.miptex.at(i);