mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1014 B
35 lines
1014 B
name: duk_load_function
|
|
|
|
proto: |
|
|
void duk_load_function(duk_context *ctx);
|
|
|
|
stack: |
|
|
[ ... bytecode! ] -> [ ... function! ]
|
|
|
|
summary: |
|
|
<p>Load a buffer containing
|
|
<a href="https://github.com/svaarala/duktape/blob/master/doc/bytecode.rst">bytecode</a>,
|
|
recreating the original ECMAScript function (with some limitations). You <b>must</b>
|
|
ensure that the bytecode has been dumped with a compatible Duktape version and that the
|
|
bytecode has not been modified since. <b>Loading bytecode from an untrusted source is
|
|
memory unsafe and may lead to exploitable vulnerabilities.</b></p>
|
|
|
|
<p include="bytecode-moreinfo.html" />
|
|
|
|
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
|
|
|