Join GitHub today
__FILE__ crash #3485
Following causes a crash:
mrb_state * mrb = mrb_open(); mrb_load_string( mrb, "__FILE__" );
The culprit is the strlen check here:
It is my understanding that strlen( NULL ) is undefined behaviour. I expect there are platforms that will return 0 for this case and thus silently continue.
Removing the assert and changing 157 to check for NULL fixes the crash:
// mrb_assert(irep->filename); fn_len = irep->filename ? strlen(irep->filename) : 0;
I don't consider this a solution as it results in __FILE__ printing as (null), rather than anything meaningful.
In the case of __FILE__ without a file-name, what is the expected output? Is there a mechanism for defining the value for __FILE__?