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