mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-19 11:53:05 +00:00
* Fix undefined behavior. Closes #5422 * Move check into callers of make_space
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
550b386995
commit
7d7d796cd0
@@ -880,7 +880,7 @@ class vector_downward {
|
|||||||
uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; }
|
uint8_t *data_at(size_t offset) const { return buf_ + reserved_ - offset; }
|
||||||
|
|
||||||
void push(const uint8_t *bytes, size_t num) {
|
void push(const uint8_t *bytes, size_t num) {
|
||||||
memcpy(make_space(num), bytes, num);
|
if (num > 0) { memcpy(make_space(num), bytes, num); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialized version of push() that avoids memcpy call for small data.
|
// Specialized version of push() that avoids memcpy call for small data.
|
||||||
@@ -903,6 +903,7 @@ class vector_downward {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Version for when we know the size is larger.
|
// Version for when we know the size is larger.
|
||||||
|
// Precondition: zero_pad_bytes > 0
|
||||||
void fill_big(size_t zero_pad_bytes) {
|
void fill_big(size_t zero_pad_bytes) {
|
||||||
memset(make_space(zero_pad_bytes), 0, zero_pad_bytes);
|
memset(make_space(zero_pad_bytes), 0, zero_pad_bytes);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user