mirror of
https://github.com/minetest/minetest.git
synced 2024-07-04 15:05:27 +02:00
Fix potential wraparound issue
This commit is contained in:
parent
d33da30fed
commit
50d5ab3241
@ -68,7 +68,7 @@ class Points {
|
|||||||
//! Empty
|
//! Empty
|
||||||
Points() : n(0), coords(nullptr) {}
|
Points() : n(0), coords(nullptr) {}
|
||||||
//! Allocating constructor; leaves coords uninitialized!
|
//! Allocating constructor; leaves coords uninitialized!
|
||||||
Points(Idx n) : n(n), coords(new Component[Dim * n]) {}
|
Points(Idx n) : n(n), coords(new Component[Dim * static_cast<std::size_t>(n)]) {}
|
||||||
//! Copying constructor
|
//! Copying constructor
|
||||||
Points(Idx n, const std::array<Component const *, Dim> &coords) : Points(n) {
|
Points(Idx n, const std::array<Component const *, Dim> &coords) : Points(n) {
|
||||||
for (uint8_t d = 0; d < Dim; ++d)
|
for (uint8_t d = 0; d < Dim; ++d)
|
||||||
@ -92,13 +92,13 @@ class Points {
|
|||||||
begin(d)[i] = point[d];
|
begin(d)[i] = point[d];
|
||||||
}
|
}
|
||||||
Component *begin(uint8_t d) {
|
Component *begin(uint8_t d) {
|
||||||
return coords.get() + d * n;
|
return coords.get() + d * static_cast<std::size_t>(n);
|
||||||
}
|
}
|
||||||
Component *end(uint8_t d) {
|
Component *end(uint8_t d) {
|
||||||
return begin(d) + n;
|
return begin(d) + n;
|
||||||
}
|
}
|
||||||
const Component *begin(uint8_t d) const {
|
const Component *begin(uint8_t d) const {
|
||||||
return coords.get() + d * n;
|
return coords.get() + d * static_cast<std::size_t>(n);
|
||||||
}
|
}
|
||||||
const Component *end(uint8_t d) const {
|
const Component *end(uint8_t d) const {
|
||||||
return begin(d) + n;
|
return begin(d) + n;
|
||||||
|
Loading…
Reference in New Issue
Block a user