summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-04-01 14:13:06 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2019-04-01 14:13:06 +0900
commit2871d0cdc5e5ef952d27187b5488888bbd18c5b0 (patch)
tree8167e5b1914548d62bcb14ac32b0f1411fe39172 /include
parent6ec855a38e8116e4f0d04f188e948046b47af74f (diff)
downloadmruby-2871d0cdc5e5ef952d27187b5488888bbd18c5b0.tar.gz
mruby-2871d0cdc5e5ef952d27187b5488888bbd18c5b0.zip
Avoid keeping pointers from `mrb_sym2name_len()`; fix #4342
The addresses for packed inline symbols reference `mrb->symbuf` that could be overridden by the later call of `mrb_sym2name_len`. Since file names in call stack information are kept as symbols, keeping the address in the C structures could cause problems like #4342. This changes small incompatible changes in function prototypes: * `mrb_parser_get_filename`: return value changed to `mrb_sym`. * `mrb_debug_get_filename`: add `mrb_state*` as a first argument. * `mrb_debug_get_line`: ditto. I believe above functions are almost internal, and no third-party mrbgem use them.
Diffstat (limited to 'include')
-rw-r--r--include/mruby/compile.h4
-rw-r--r--include/mruby/debug.h5
2 files changed, 4 insertions, 5 deletions
diff --git a/include/mruby/compile.h b/include/mruby/compile.h
index fd735be88..f19d9b0b3 100644
--- a/include/mruby/compile.h
+++ b/include/mruby/compile.h
@@ -118,7 +118,7 @@ struct mrb_parser_state {
FILE *f;
#endif
mrbc_context *cxt;
- char const *filename;
+ mrb_sym filename_sym;
int lineno;
int column;
@@ -168,7 +168,7 @@ MRB_API void mrb_parser_free(struct mrb_parser_state*);
MRB_API void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*);
MRB_API void mrb_parser_set_filename(struct mrb_parser_state*, char const*);
-MRB_API char const* mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
+MRB_API mrb_sym mrb_parser_get_filename(struct mrb_parser_state*, uint16_t idx);
/* utility functions */
#ifndef MRB_DISABLE_STDIO
diff --git a/include/mruby/debug.h b/include/mruby/debug.h
index f0a40dfcf..e08c47cfc 100644
--- a/include/mruby/debug.h
+++ b/include/mruby/debug.h
@@ -26,7 +26,6 @@ typedef struct mrb_irep_debug_info_line {
typedef struct mrb_irep_debug_info_file {
uint32_t start_pos;
- const char *filename;
mrb_sym filename_sym;
uint32_t line_entry_count;
mrb_debug_line_type line_type;
@@ -47,13 +46,13 @@ typedef struct mrb_irep_debug_info {
* get line from irep's debug info and program counter
* @return returns NULL if not found
*/
-MRB_API const char *mrb_debug_get_filename(mrb_irep *irep, ptrdiff_t pc);
+MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc);
/*
* get line from irep's debug info and program counter
* @return returns -1 if not found
*/
-MRB_API int32_t mrb_debug_get_line(mrb_irep *irep, ptrdiff_t pc);
+MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, mrb_irep *irep, ptrdiff_t pc);
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(