diff --git a/dawn.json b/dawn.json index 79e5f4e23c..4151b95368 100644 --- a/dawn.json +++ b/dawn.json @@ -572,7 +572,7 @@ {"name": "group index", "type": "uint32_t"}, {"name": "group", "type": "bind group"}, {"name": "dynamic offset count", "type": "uint32_t", "default": "0"}, - {"name": "dynamic offsets", "type": "uint32_t", "annotation": "const*", "length": "dynamic offset count", "optional": true} + {"name": "dynamic offsets", "type": "uint32_t", "annotation": "const*", "length": "dynamic offset count", "default": "nullptr"} ] }, { @@ -1229,7 +1229,7 @@ {"name": "group index", "type": "uint32_t"}, {"name": "group", "type": "bind group"}, {"name": "dynamic offset count", "type": "uint32_t", "default": "0"}, - {"name": "dynamic offsets", "type": "uint32_t", "annotation": "const*", "length": "dynamic offset count", "optional": true} + {"name": "dynamic offsets", "type": "uint32_t", "annotation": "const*", "length": "dynamic offset count", "default": "nullptr"} ] }, { @@ -1393,7 +1393,7 @@ {"name": "group index", "type": "uint32_t"}, {"name": "group", "type": "bind group"}, {"name": "dynamic offset count", "type": "uint32_t", "default": "0"}, - {"name": "dynamic offsets", "type": "uint32_t", "annotation": "const*", "length": "dynamic offset count", "optional": true} + {"name": "dynamic offsets", "type": "uint32_t", "annotation": "const*", "length": "dynamic offset count", "default": "nullptr"} ] }, { diff --git a/generator/templates/dawn_wire/WireCmd.cpp b/generator/templates/dawn_wire/WireCmd.cpp index 4816ee122c..2c372905b0 100644 --- a/generator/templates/dawn_wire/WireCmd.cpp +++ b/generator/templates/dawn_wire/WireCmd.cpp @@ -361,6 +361,10 @@ namespace { {% set memberName = as_varName(member.name) %} {% if member.type.category != "object" and member.optional %} + //* Non-constant length optional members use length=0 to denote they aren't present. + //* Otherwise we could have length=N and has_member=false, causing reads from an + //* uninitialized pointer. + {{ assert(member.length == "constant") }} bool has_{{memberName}} = transfer->has_{{memberName}}; record->{{memberName}} = nullptr; if (has_{{memberName}})