name: duk_load_function proto: | void duk_load_function(duk_context *ctx); stack: | [ ... bytecode! ] -> [ ... function! ] summary: |
Load a buffer containing bytecode, recreating the original Ecmascript function (with some limitations). You must ensure that the bytecode has been dumped with a compatible Duktape version and that the bytecode has not been modified since. Loading bytecode from an untrusted source is memory unsafe and may load to exploitable vulnerabilities.
example: | duk_eval_string(ctx, "(function helloWorld() { print('hello world'); })"); duk_dump_function(ctx); /* stack top now contains a buffer containing helloWorld bytecode */ duk_load_function(ctx); /* [ ... bytecode ] -> [ ... function ] */ duk_call(ctx, 0); duk_pop(ctx); tags: - stack - bytecode seealso: - duk_dump_function introduced: 1.3.0