Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a56d901 authored by Myles Watson's avatar Myles Watson
Browse files

PDL: Always check IsValid in FromView

If there are no parameters for a builder, the view may be
unused.  Check to see if the view is valid before returning
a corresponding builder.

Bug: 302317771
Test: mma -j32
Change-Id: I7120c60cf139f964aafec2a7e475aa19fbad9129
parent 766108fa
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -436,6 +436,7 @@ void PacketDef::GenTestingFromView(std::ostream& s) const {
  s << "#if defined(PACKET_FUZZ_TESTING) || defined(PACKET_TESTING) || defined(FUZZ_TARGET)\n";

  s << "static std::unique_ptr<" << name_ << "Builder> FromView(" << name_ << "View view) {";
  s << "if (!view.IsValid()) return nullptr;";
  s << "return " << name_ << "Builder::Create(";
  FieldList params = GetParamList().GetFieldsWithoutTypes({
      BodyField::kFieldType,