zrax / pycdc

C++ python bytecode disassembler and decompiler
GNU General Public License v3.0
3.38k stars 646 forks source link

fix: incorrect error message in `ASTree::BuildFromCode(...)` #511

Open wilson0x4d opened 3 months ago

wilson0x4d commented 3 months ago
wilson0x4d commented 3 months ago

indeed, i overlooked the EXTENDED_ARG handling.

the update i've pushed instead relies on bc_next to pass bytecode back up to the caller, this seems cleaner (doesn't couple the code to code()->value()) and compensates for EXTENDED_ARG correctly. this does leave the position printed off by a few bytes (when EXTENDED_ARG), but the bytecode value becomes accurate (which is what I was really looking for in the output) and even being a few bytes off at least gets someone who understands the bytecode into the right area of the image (where they would see EXTENDED_ARG and could mentally compensate.)

i also updated the disasm code with a similar change (to include the offending bytecode in the output.)