dawn/node: Avoid empty vector index

If a device lists no features, don't zero-index an empty std::vector.

Change-Id: I10d632f0c5d5a162abec180797ad11adee67fc6b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116863
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2023-01-11 20:05:37 +00:00 committed by Dawn LUCI CQ
parent 47a81fc126
commit 58d1e89426

View File

@ -181,7 +181,9 @@ GPUDevice::~GPUDevice() {
interop::Interface<interop::GPUSupportedFeatures> GPUDevice::getFeatures(Napi::Env env) {
size_t count = device_.EnumerateFeatures(nullptr);
std::vector<wgpu::FeatureName> features(count);
device_.EnumerateFeatures(&features[0]);
if (count > 0) {
device_.EnumerateFeatures(features.data());
}
return interop::GPUSupportedFeatures::Create<GPUSupportedFeatures>(env, env,
std::move(features));
}