Skip to main content

Try it Live

Run Bytecode examples in the interactive playground

bytecode_t bytecode_init(const uint8_t* code, size_t code_len)

Validation happens during initialization. Invalid bytecode returns null.
#include "voltaire.h"

// Valid bytecode
uint8_t code[] = {0x60, 0x01};
bytecode_t bc = bytecode_init(code, 2);
if (bc == NULL) {
    // Invalid bytecode
}
bytecode_free(bc);

// Invalid bytecode (PUSH1 with no data)
uint8_t invalid[] = {0x60};
bytecode_t bc_invalid = bytecode_init(invalid, 1);
if (bc_invalid == NULL) {
    // Invalid bytecode caught
}
Defined in: src/primitives.h

See Also

  • analyze - Complete analysis including validation