continue parsing the application instead of falling when encontering invalid code

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2025-01-28 14:46:36 +01:00
parent 0990b8a9b2
commit 0e2bb5fe2d
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2

View file

@ -7,7 +7,7 @@ use std::fs::File;
use std::io::Cursor;
use std::path::PathBuf;
use log::info;
use log::{error, info};
#[cfg(feature = "python")]
use pyo3::{prelude::*, types::PyBytes};
@ -804,11 +804,19 @@ impl Apk {
let code = if code_off == 0 {
None
} else {
Some(
Self::get_code_from_off(code_off, dex, label_each_ins).with_context(|| {
format!("Failed to parse code of method {}", descriptor.__str__())
})?,
)
match Self::get_code_from_off(code_off, dex, label_each_ins)
.with_context(|| format!("Failed to parse code of method {}", descriptor.__str__()))
{
Err(e) => {
error!(
"Code of {} could not be loaded: {}",
descriptor.__str__(),
e
);
None
}
Ok(code) => Some(code),
}
};
Ok(Method {