mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Fix memory corruption when loading encoded embedded images in C++ (#2542)
The ImageCacheKey enum has a gap when not targeting wasm: ``` pub enum ImageCacheKey { /// This variant indicates that no image cache key can be created for the image. /// For example this is the case for programmatically created images. Invalid, /// The image is identified by its path on the file system. Path(SharedString), /// The image is identified by a URL. #[cfg(target_arch = "wasm32")] URL(SharedString), /// The image is identified by the static address of its encoded data. EmbeddedData(usize), } ``` In the C++ generated header, that cfg was not mapped, and thus the URL variant was always there, while in a regular slint-cpp build it's not. Consequently tag value 2 in Rust was used to represent the EmbeddedData variant, while in the C++ generated code that become variant 3 and 2 was interpreted as a URL. So the receiving code in C++ tried to interpret the cache key as URL variant, while Rust created it as EmbeddedData. Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
This commit is contained in:
parent
ea769cb10c
commit
004dce6c0b
2 changed files with 2 additions and 0 deletions
|
@ -75,6 +75,7 @@ fn default_config() -> cbindgen::Config {
|
|||
defines: [
|
||||
("target_pointer_width = 64".into(), "SLINT_TARGET_64".into()),
|
||||
("target_pointer_width = 32".into(), "SLINT_TARGET_32".into()),
|
||||
("target_arch = wasm32".into(), "SLINT_TARGET_WASM".into()), // Disable any wasm guarded code in C++, too - so that there are no gaps in enums.
|
||||
]
|
||||
.iter()
|
||||
.cloned()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue