cs_disasm_iter: return early on zero-size input (#2886) (#2920)

Prevent calling backend decoder with no remaining bytes,
which could lead to out-of-bounds reads.

Co-authored-by: Petar Andrić <slate@null.net>
This commit is contained in:
Rot127 2026-05-14 10:23:59 +00:00 committed by GitHub
parent 30d610cd65
commit 2de76ae94d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

3
cs.c
View file

@ -1114,6 +1114,9 @@ CAPSTONE_EXPORT
bool CAPSTONE_API cs_disasm_iter(csh ud, const uint8_t **code, size_t *size,
uint64_t *address, cs_insn *insn)
{
if (*size == 0)
return false;
struct cs_struct *handle;
uint16_t insn_size;
MCInst mci;