diff options
author | David LeGare <legare@google.com> | 2022-06-28 17:02:59 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-06-28 17:02:59 +0000 |
commit | 39e5e7c8e4fafdd449d9b4aeae34de94c1024bae (patch) | |
tree | a18c2ea6fdd6e314c929c90d64215abf6257c919 | |
parent | b5c352f02a704aaadbc87b87341ceca99c257392 (diff) | |
parent | 9477508b6a46654a78049c6a744194af7dc6f684 (diff) | |
download | derive_arbitrary-39e5e7c8e4fafdd449d9b4aeae34de94c1024bae.tar.gz |
Upgrade rust/crates/derive_arbitrary to 1.1.3 am: ae65bf6550 am: d275059840 am: 02f5e2d96d am: 9477508b6a
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/derive_arbitrary/+/2137476
Change-Id: I30f2637667aa95c8daeed0e4ea1f32e7d91412b7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | src/lib.rs | 45 |
6 files changed, 35 insertions, 24 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 0f0db8a..30c0308 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "34be5b6d3d3bb513358e80453984652c88e07b75" + "sha1": "8e7b857f4f78b06920a36212ed2f392bc523c1f6" }, "path_in_vcs": "derive" }
\ No newline at end of file @@ -43,7 +43,7 @@ rust_proc_macro { name: "libderive_arbitrary", crate_name: "derive_arbitrary", cargo_env_compat: true, - cargo_pkg_version: "1.1.2", + cargo_pkg_version: "1.1.3", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ @@ -12,7 +12,7 @@ [package] edition = "2018" name = "derive_arbitrary" -version = "1.1.2" +version = "1.1.3" authors = [ "The Rust-Fuzz Project Developers", "Nick Fitzgerald <fitzgen@gmail.com>", diff --git a/Cargo.toml.orig b/Cargo.toml.orig index e9b0c31..6896426 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "derive_arbitrary" -version = "1.1.2" # Make sure it matches the version of the arbitrary crate itself. +version = "1.1.3" # Make sure it matches the version of the arbitrary crate itself. authors = [ "The Rust-Fuzz Project Developers", "Nick Fitzgerald <fitzgen@gmail.com>", @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/derive_arbitrary/derive_arbitrary-1.1.2.crate" + value: "https://static.crates.io/crates/derive_arbitrary/derive_arbitrary-1.1.3.crate" } - version: "1.1.2" + version: "1.1.3" license_type: NOTICE last_upgrade_date { year: 2022 month: 6 - day: 23 + day: 27 } } @@ -35,15 +35,17 @@ pub fn derive_arbitrary(tokens: proc_macro::TokenStream) -> proc_macro::TokenStr let (_, ty_generics, where_clause) = generics.split_for_impl(); (quote! { - thread_local! { - #[allow(non_upper_case_globals)] - static #recursive_count: std::cell::Cell<u32> = std::cell::Cell::new(0); - } + const _: () = { + thread_local! { + #[allow(non_upper_case_globals)] + static #recursive_count: std::cell::Cell<u32> = std::cell::Cell::new(0); + } - impl #impl_generics arbitrary::Arbitrary<#lifetime_without_bounds> for #name #ty_generics #where_clause { - #arbitrary_method - #size_hint_method - } + impl #impl_generics arbitrary::Arbitrary<#lifetime_without_bounds> for #name #ty_generics #where_clause { + #arbitrary_method + #size_hint_method + } + }; }) .into() } @@ -83,17 +85,26 @@ fn with_recursive_count_guard( expr: impl quote::ToTokens, ) -> impl quote::ToTokens { quote! { - #recursive_count.with(|count| { - if count.get() > 0 && u.is_empty() { - return Err(arbitrary::Error::NotEnoughData); - } + let guard_against_recursion = u.is_empty(); + if guard_against_recursion { + #recursive_count.with(|count| { + if count.get() > 0 { + return Err(arbitrary::Error::NotEnoughData); + } + count.set(count.get() + 1); + Ok(()) + })?; + } + + let result = (|| { #expr })(); - count.set(count.get() + 1); - let result = { #expr }; - count.set(count.get() - 1); + if guard_against_recursion { + #recursive_count.with(|count| { + count.set(count.get() - 1); + }); + } - result - }) + result } } |