Skip to content

Commit

Permalink
4.4.1: register_raw_format() should not accept empty input
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh committed Jan 24, 2022
1 parent 4a5b7aa commit fff3d3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "clipboard-win"
version = "4.4.0"
version = "4.4.1"
authors = ["Douman <douman@gmx.se>"]
description = "Provides simple way to interact with Windows clipboard."
license = "BSL-1.0"
Expand Down
4 changes: 2 additions & 2 deletions src/raw.rs
Expand Up @@ -784,7 +784,7 @@ pub fn format_name_big(format: u32) -> Option<String> {
///- Custom format identifier is in range `0xC000...0xFFFF`.
///- Function fails if input is not null terminated string.
pub unsafe fn register_raw_format(name: &[u16]) -> Option<NonZeroU32> {
if name[name.len()-1] != b'\0' as u16 {
if name.is_empty() || name[name.len()-1] != b'\0' as u16 {
return unlikely_empty_size_result()
}
NonZeroU32::new(RegisterClipboardFormatW(name.as_ptr()) )
Expand All @@ -805,7 +805,7 @@ pub fn register_format(name: &str) -> Option<NonZeroU32> {
};

if size == 0 {
return None;
return unlikely_empty_size_result()
}

if size > 52 {
Expand Down

0 comments on commit fff3d3e

Please sign in to comment.