Ensure that string and container are initialized before use

On OSX, under ASAN the fuzzer is causing a null reference due to
.empty() being called on a null.

BUG=chromium:1237630

Change-Id: I73e627eadaa162af451f809c4abe8ec685d8b95c
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/61681
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
Ryan Harrison 2021-08-12 03:40:31 +00:00 committed by Tint LUCI CQ
parent 3bcbfc7862
commit b73a12cc5d
2 changed files with 3 additions and 2 deletions

View File

@ -115,7 +115,7 @@ struct FuzzerCliParams {
FuzzingTarget fuzzing_target = FuzzingTarget::kAll;
/// The path to the directory, that will be used to output buggy shaders.
std::string error_dir;
std::string error_dir = "";
/// Parameters for various mutators.
MutatorCliParams mutator_params;

View File

@ -226,7 +226,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
spv_to_wgsl.Run(data, size);
if (spv_to_wgsl.HasErrors()) {
auto error = spv_to_wgsl.Diagnostics().str();
util::LogSpvError(error, data, size, context->params.error_dir);
util::LogSpvError(error, data, size,
context ? context->params.error_dir : "");
return 0;
}