mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 15:47:26 +00:00
Fix array index access at negative index
Conversion from negative float to unsigned is saturating to 0 in rust and undefined behavior in C++, we should therefore handle the case properly Fixes #8222
This commit is contained in:
parent
ff6065ace4
commit
cd8ab8ce53
6 changed files with 24 additions and 10 deletions
|
@ -25,9 +25,9 @@ struct ModelChangeListener
|
|||
using ModelPeer = std::weak_ptr<ModelChangeListener>;
|
||||
|
||||
template<typename M>
|
||||
auto access_array_index(const std::shared_ptr<M> &model, size_t index)
|
||||
auto access_array_index(const std::shared_ptr<M> &model, std::ptrdiff_t index)
|
||||
{
|
||||
if (!model) {
|
||||
if (!model || index < 0) {
|
||||
return decltype(*model->row_data_tracked(index)) {};
|
||||
} else if (const auto v = model->row_data_tracked(index)) {
|
||||
return *v;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue