From 56f0ed68c1a50862e4c779f6b65de6333c4f726b Mon Sep 17 00:00:00 2001 From: Jiulong Wang Date: Wed, 17 May 2023 19:01:51 -0700 Subject: [PATCH] refine per review comments --- src/google/protobuf/parse_context.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 446cda8fb1..a443ca4c4d 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -138,19 +138,21 @@ class PROTOBUF_EXPORT EpsCopyInputStream { // - Every non-empty token is moved from and consumed. class LimitToken { public: - LimitToken() { PROTOBUF_POISON_MEMORY_REGION(this, sizeof(LimitToken)); } - explicit LimitToken(int token) : token_(token) { PROTOBUF_UNPOISON_MEMORY_REGION(this, sizeof(LimitToken)); } + LimitToken() { PROTOBUF_POISON_MEMORY_REGION(&token_, sizeof(token_)); } + explicit LimitToken(int token) : token_(token) { + PROTOBUF_UNPOISON_MEMORY_REGION(&token_, sizeof(token_)); + } LimitToken(LimitToken&& other) { *this = std::move(other); } LimitToken& operator=(LimitToken&& other) { - PROTOBUF_UNPOISON_MEMORY_REGION(this, sizeof(LimitToken)); + PROTOBUF_UNPOISON_MEMORY_REGION(&token_, sizeof(token_)); token_ = other.token_; - PROTOBUF_POISON_MEMORY_REGION(&other, sizeof(LimitToken)); + PROTOBUF_POISON_MEMORY_REGION(&other.token_, sizeof(token_)); return *this; } ~LimitToken() { #ifdef ADDRESS_SANITIZER - ABSL_CHECK(__asan_address_is_poisoned(this)); + ABSL_CHECK(__asan_address_is_poisoned(&token_)); #endif } @@ -158,13 +160,9 @@ class PROTOBUF_EXPORT EpsCopyInputStream { LimitToken& operator=(const LimitToken&) = delete; int token() && { -#ifdef ADDRESS_SANITIZER int t = token_; - PROTOBUF_POISON_MEMORY_REGION(this, sizeof(LimitToken)); + PROTOBUF_POISON_MEMORY_REGION(&token_, sizeof(token_)); return t; -#else - return token_; -#endif } private: