Fix dropdown fuzzer. (#243)

This commit is contained in:
Arthur Sonzogni 2021-10-22 14:04:07 +02:00 committed by GitHub
parent 313ce9c35f
commit f80d9b5cfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -1,9 +1,13 @@
Changelog
=========
released (development)
unreleased (development)
------------------------
# Bug:
- Check the selected element are within bounds for Dropdown.
0.11
----

View File

@ -57,7 +57,7 @@ Component GeneratorComponent(const char*& data, size_t& size, int depth) {
if (depth <= 0)
return Button(GeneratorString(data, size), [] {});
switch (value % 18) {
switch (value % 19) {
case 1:
return Checkbox(GeneratorString(data, size), &g_bool);
case 2:

View File

@ -1,3 +1,4 @@
#include <cmath>
#include <memory> // for __shared_ptr_access
#include <string> // for string
#include <utility> // for move
@ -28,6 +29,7 @@ Component Dropdown(ConstStringListRef entries, int* selected) {
}
Element Render() override {
*selected_ = std::min((int)entries_.size() - 1, std::max(0, *selected_));
title_ = entries_[*selected_];
if (show_) {
return vbox({