pycdc icon indicating copy to clipboard operation
pycdc copied to clipboard

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

Open wilson0x4d opened this issue 1 year ago • 1 comments

  • opcode was incorrectly clamped causing misleading output.

  • modified output with additional info about offending bytecode and position so end-user submissions can become more informative.

wilson0x4d avatar Aug 13 '24 18:08 wilson0x4d

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.)

wilson0x4d avatar Aug 14 '24 17:08 wilson0x4d