summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSnappy Team <no-reply@google.com>2020-11-02 17:46:36 +0000
committerVictor Costan <costan@google.com>2020-11-03 20:30:24 +0000
commit1ce58af28e46872d003f3a38213815595f387a39 (patch)
tree88cd618489515703c79fce73d5bcc9c6fccd0469
parent0b990db2b80a5c4522de441a28cce2cd10be382d (diff)
downloadsnappy-git-1ce58af28e46872d003f3a38213815595f387a39.tar.gz
Fix the use of op + len when op is nullptr and len is non-zero.
See https://reviews.llvm.org/D67122 for some discussion of why this can matter. I don't think this should have any noticeable effect on performance. PiperOrigin-RevId: 340255083
-rw-r--r--snappy.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/snappy.cc b/snappy.cc
index 605e0f5..29e1e8e 100644
--- a/snappy.cc
+++ b/snappy.cc
@@ -1569,15 +1569,14 @@ class SnappyScatteredWriter {
static_cast<size_t>(op - op_base_) < offset ||
op >= op_limit_min_slop_ || offset < len)) {
if (offset == 0) return false;
- char* const op_end = op + len;
if (SNAPPY_PREDICT_FALSE(static_cast<size_t>(op - op_base_) < offset ||
- op_end > op_limit_)) {
+ op + len > op_limit_)) {
op_ptr_ = op;
bool res = SlowAppendFromSelf(offset, len);
*op_p = op_ptr_;
return res;
}
- *op_p = IncrementalCopy(op - offset, op, op_end, op_limit_);
+ *op_p = IncrementalCopy(op - offset, op, op + len, op_limit_);
return true;
}
// Fast path