From 0cdd932ef7da826adfd42655152551667b360a54 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 13 Mar 2024 01:35:12 -0400 Subject: [PATCH] fix a use-after-move --- light/write.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/light/write.cc b/light/write.cc index c6ca357c..4f8ca918 100644 --- a/light/write.cc +++ b/light/write.cc @@ -1073,11 +1073,16 @@ void SaveLightmapSurfaces(bspdata_t *bspdata, const fs::path &source) logging::print("Lighting Completed.\n\n"); + if (light_options.write_litfile == lightfile::lit2) { + WriteLitFile(bsp, faces_sup, source, 2, lit_filebase, lux_filebase); + return; // run away before any files are written + } + // Transfer greyscale lightmap (or color lightmap for Q2/HL) to the bsp and update lightdatasize // NOTE: bsp.lightdatasize is already valid in the -litonly case if (!light_options.litonly.value()) { if (bsp->loadversion->game->has_rgb_lightmap) { - bsp->dlightdata = std::move(lit_filebase); + bsp->dlightdata = lit_filebase; // not moved, because it's used below too } else { bsp->dlightdata = std::move(filebase); } @@ -1086,11 +1091,6 @@ void SaveLightmapSurfaces(bspdata_t *bspdata, const fs::path &source) bspdata->bspx.entries.erase("RGBLIGHTING"); bspdata->bspx.entries.erase("LIGHTINGDIR"); - if (light_options.write_litfile == lightfile::lit2) { - WriteLitFile(bsp, faces_sup, source, 2, lit_filebase, lux_filebase); - return; // run away before any files are written - } - /*fixme: add a new per-surface offset+lmscale lump for compat/versitility?*/ if (light_options.write_litfile & lightfile::external) { WriteLitFile(bsp, faces_sup, source, LIT_VERSION, lit_filebase, lux_filebase);