add check sort
This commit is contained in:
parent
d5b8222491
commit
736c4611ac
3 changed files with 16 additions and 1 deletions
|
|
@ -56,6 +56,18 @@ impl Serializable for EncodedAnnotation {
|
|||
for _ in 0..size {
|
||||
elements.push(AnnotationElement::deserialize(input)?);
|
||||
}
|
||||
if !elements.is_empty() {
|
||||
let mut idx_0 = elements[0].name_idx;
|
||||
for idx_1 in elements.iter().map(|elt| elt.name_idx).skip(1) {
|
||||
if idx_0 > idx_1 {
|
||||
// TODO: use proper logging
|
||||
println!(
|
||||
"Waring while deserializing EncodedAnnotation: element must be sorted in increasing order by string_id index, found {idx_0:?} before {idx_1:?}"
|
||||
);
|
||||
}
|
||||
idx_0 = idx_1;
|
||||
}
|
||||
}
|
||||
Ok(Self { type_idx, elements })
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,3 +41,5 @@ impl Serializable for EncodedArray {
|
|||
self.size_field().size() + self.values.iter().map(|val| val.size()).sum::<usize>()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add tests
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
use crate::{EncodedAnnotation, EncodedArray, Error, ReadSeek, Result, Serializable};
|
||||
use std::io::Write;
|
||||
|
||||
// TODO: TESTS!!!
|
||||
/// An encoded value of arbitrary hierachically structured data:
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#encoding
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -669,3 +668,5 @@ impl Serializable for Idx {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: TESTS!!!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue