Skip to content

Commit bbe73b5

Browse files
authored
Use LOG_DEBUG() to reference arr[]
1 parent fed0ed4 commit bbe73b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/cli/main.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#define STB_IMAGE_RESIZE_STATIC
2323
#include "stb_image_resize.h"
2424

25+
#include "util.h"
26+
2527
const char* rng_type_to_str[] = {
2628
"std_default",
2729
"cuda",
@@ -825,7 +827,6 @@ int main(int argc, const char* argv[]) {
825827
bool vae_decode_only = true;
826828
uint8_t* input_image_buffer = NULL;
827829
uint8_t* control_image_buffer = NULL;
828-
uint8_t* mask_image_buffer = NULL;
829830

830831
if (params.mode == IMG2IMG || params.mode == IMG2VID) {
831832
vae_decode_only = false;
@@ -999,15 +1000,18 @@ int main(int argc, const char* argv[]) {
9991000
free_sd_ctx(sd_ctx);
10001001
return 0;
10011002
} else {
1003+
uint8_t* mask_image_buffer = NULL;
10021004
if (params.mask_path != "") {
10031005
int c = 0;
10041006
mask_image_buffer = stbi_load(params.mask_path.c_str(), &params.width, &params.height, &c, 1);
10051007
} else {
10061008
std::vector<uint8_t> arr(params.width * params.height, 255);
1007-
for (uint8_t dummy_arr : arr) if (dummy_arr) break; // dummy cycle to avoid -O3 optimization
1009+
// do not remove this LOG_DEBUG line, or -O3 may destroy arr[]
1010+
// before assigning to mask_image_buffer
1011+
LOG_DEBUG("img2img: created array with 0x%x fill", arr[0]);
10081012
mask_image_buffer = arr.data();
10091013
}
1010-
sd_image_t mask_image = {(uint32_t)params.width,
1014+
const sd_image_t mask_image = {(uint32_t)params.width,
10111015
(uint32_t)params.height,
10121016
1,
10131017
mask_image_buffer};

0 commit comments

Comments
 (0)