mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-27 05:30:23 +02:00
Properly correct read of freed memory
This commit is contained in:
parent
20955b2bfc
commit
1507bc7ee5
3 changed files with 17 additions and 7 deletions
|
@ -1068,10 +1068,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
@rem{/* call the generated code@comma{} passing its size as argument */}
|
@rem{/* call the generated code@comma{} passing its size as argument */}
|
||||||
myFunction((char*)jit_address(end) - (char*)jit_address(start));
|
myFunction((char*)jit_address(end) - (char*)jit_address(start));
|
||||||
|
jit_clear_state();
|
||||||
|
|
||||||
jit_disassemble();
|
jit_disassemble();
|
||||||
|
|
||||||
jit_clear_state();
|
|
||||||
jit_destroy_state();
|
jit_destroy_state();
|
||||||
finish_jit();
|
finish_jit();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1127,15 +1127,15 @@ call must be done after the @code{emit} call or either a fatal error
|
||||||
will happen (if @lightning{} is built with assertions enable) or an
|
will happen (if @lightning{} is built with assertions enable) or an
|
||||||
undefined value will be returned.
|
undefined value will be returned.
|
||||||
|
|
||||||
@item jit_disassemble();
|
|
||||||
@code{disassemble} will dump the generated code to standard output,
|
|
||||||
unless @lightning{} was built with the disassembler disabled, in which
|
|
||||||
case no output will be shown.
|
|
||||||
|
|
||||||
@item jit_clear_state();
|
@item jit_clear_state();
|
||||||
Note that @code{jit_clear_state} was called after executing jit in
|
Note that @code{jit_clear_state} was called after executing jit in
|
||||||
this example. It was done because it must be called after any call
|
this example. It was done because it must be called after any call
|
||||||
to @code{jit_address} or @code{jit_print}.
|
to @code{jit_address} or @code{jit_print}.
|
||||||
|
|
||||||
|
@item jit_disassemble();
|
||||||
|
@code{disassemble} will dump the generated code to standard output,
|
||||||
|
unless @lightning{} was built with the disassembler disabled, in which
|
||||||
|
case no output will be shown.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node RPN calculator
|
@node RPN calculator
|
||||||
|
|
|
@ -30,10 +30,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* call the generated code, passing its size as argument */
|
/* call the generated code, passing its size as argument */
|
||||||
myFunction((char*)jit_address(end) - (char*)jit_address(start));
|
myFunction((char*)jit_address(end) - (char*)jit_address(start));
|
||||||
|
jit_clear_state();
|
||||||
|
|
||||||
jit_disassemble();
|
jit_disassemble();
|
||||||
|
|
||||||
jit_clear_state();
|
|
||||||
jit_destroy_state();
|
jit_destroy_state();
|
||||||
finish_jit();
|
finish_jit();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -832,6 +832,13 @@ jit_new_state(void)
|
||||||
void
|
void
|
||||||
_jit_clear_state(jit_state_t *_jit)
|
_jit_clear_state(jit_state_t *_jit)
|
||||||
{
|
{
|
||||||
|
#if DEVEL_DISASSEMBLER
|
||||||
|
# define jit_really_clear_state() _jit_really_clear_state(_jit)
|
||||||
|
}
|
||||||
|
|
||||||
|
void _jit_really_clear_state(jit_state_t *_jit)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
jit_word_t offset;
|
jit_word_t offset;
|
||||||
jit_function_t *function;
|
jit_function_t *function;
|
||||||
|
|
||||||
|
@ -889,6 +896,9 @@ _jit_clear_state(jit_state_t *_jit)
|
||||||
void
|
void
|
||||||
_jit_destroy_state(jit_state_t *_jit)
|
_jit_destroy_state(jit_state_t *_jit)
|
||||||
{
|
{
|
||||||
|
#if DEVEL_DISASSEMBLER
|
||||||
|
jit_really_clear_state();
|
||||||
|
#endif
|
||||||
if (!_jit->user_code)
|
if (!_jit->user_code)
|
||||||
munmap(_jit->code.ptr, _jit->code.length);
|
munmap(_jit->code.ptr, _jit->code.length);
|
||||||
if (!_jit->user_data)
|
if (!_jit->user_data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue