fix: avoid undefined behavior on image mask allocation failure (#1198)

This commit is contained in:
Wagner Bruna 2026-01-17 14:14:56 -03:00 committed by GitHub
parent 7010bb4dff
commit fbce16e02d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -594,12 +594,12 @@ int main(int argc, const char* argv[]) {
} }
} else { } else {
mask_image.data = (uint8_t*)malloc(gen_params.width * gen_params.height); mask_image.data = (uint8_t*)malloc(gen_params.width * gen_params.height);
memset(mask_image.data, 255, gen_params.width * gen_params.height);
if (mask_image.data == nullptr) { if (mask_image.data == nullptr) {
LOG_ERROR("malloc mask image failed"); LOG_ERROR("malloc mask image failed");
release_all_resources(); release_all_resources();
return 1; return 1;
} }
memset(mask_image.data, 255, gen_params.width * gen_params.height);
} }
if (gen_params.control_image_path.size() > 0) { if (gen_params.control_image_path.size() > 0) {