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

Commit adcfbf80 authored by Nick Kralevich's avatar Nick Kralevich Committed by Gerrit Code Review
Browse files

Merge "zip_archive.cc: fix ubsan false positive"

parents 8c82af24 a4e54336
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -102,21 +102,9 @@ static uint32_t RoundUpPower2(uint32_t val) {
}

static uint32_t ComputeHash(const ZipString& name) {
#if !defined(_WIN32)
  return std::hash<std::string_view>{}(
      std::string_view(reinterpret_cast<const char*>(name.name), name.name_length));
#else
  // Remove this code path once the windows compiler knows how to compile the above statement.
  uint32_t hash = 0;
  uint16_t len = name.name_length;
  const uint8_t* str = name.name;

  while (len--) {
    hash = hash * 31 + *str++;
  }

  return hash;
#endif
             std::string_view(reinterpret_cast<const char*>(name.name), name.name_length)) &
         UINT32_MAX;
}

static bool isZipStringEqual(const uint8_t* start, const ZipString& zip_string,