mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-31 00:37:39 +08:00
防止内存越界
This commit is contained in:
parent
d703ec29c6
commit
b19574cea7
@ -480,10 +480,10 @@ double AMFDecoder::load<double>() {
|
||||
if (pos + 8 > buf.size()) {
|
||||
throw std::runtime_error("Not enough data");
|
||||
}
|
||||
uint64_t val = ((uint64_t) load_be32(&buf[pos]) << 32)
|
||||
| load_be32(&buf[pos + 4]);
|
||||
uint64_t val = ((uint64_t) load_be32(&buf[pos]) << 32) | load_be32(&buf[pos + 4]);
|
||||
double n = 0;
|
||||
memcpy(&n, &val, 8);
|
||||
static_assert(sizeof(n) == sizeof(val), "sizeof(double) not eq sizeof(uint64_t)");
|
||||
memcpy(&n, &val, sizeof(n));
|
||||
pos += 8;
|
||||
return n;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user