summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2020-01-29Remove unused local variable `mid`; ref #4936Yukihiro "Matz" Matsumoto
2020-01-27Fixed backtrace message for top-level blocks; fix #4936Yukihiro "Matz" Matsumoto
In top-level, `mid` is `NULL`. We used to ignore 'mid` update for `NULL`.
2020-01-10Fixed wrong condition in #4926 fix.Yukihiro "Matz" Matsumoto
2020-01-10Fixed wrong condition for copying arguments on stack; fix #4926Yukihiro "Matz" Matsumoto
This bug was introduced in 694089f to address #4832
2020-01-08Add `MRB_WITHOUT_FLOAT` guard to `<math.h>`.Yukihiro "Matz" Matsumoto
2020-01-08Fix buffer overflow in `mrb_str_len_to_dbl`.Yukihiro "Matz" Matsumoto
Issue 19902: mruby:mruby_fuzzer: Stack-buffer-overflow in mrb_str_len_to_dbl
2020-01-07Check memory boundary in `mrb_str_len_to_dbl`.Yukihiro "Matz" Matsumoto
2020-01-06`"0x10".to_f` should be `0`, not `16.0`; fix #4924Yukihiro "Matz" Matsumoto
2020-01-06Check remaining string length before access to avoid OOB access.Yukihiro "Matz" Matsumoto
2020-01-06Need to preserve the original input string in `mrb_str_len_to_dbl`.Yukihiro "Matz" Matsumoto
2020-01-06Fix `mrb_str_len_to_dbl` to support Hexadecimal like `0x10`.Yukihiro "Matz" Matsumoto
2020-01-06Refactor `mrb_cstr_to_dbl`; ref #4920Yukihiro "Matz" Matsumoto
2020-01-06Avoid creating temporary objects in `read_irep_record_1`; close #4920Yukihiro "Matz" Matsumoto
The basic idea of this change is from @dearblue. Note: the arguments of `mrb_str_pool()` have changed, but the function is provided for internal use (No `MRB_API`). So basically you don't have to worry about the change.
2020-01-02Call `va_end()` before returndearblue
The behavior when returning from a function without `va_end()` is undefined.
2020-01-01Rename `mrb_num_args_error` to `mrb_argnum_error`; ref #4863Yukihiro "Matz" Matsumoto
2020-01-01Merge pull request #4863 from ↵Yukihiro "Matz" Matsumoto
shuujii/add-mrb_num_args_error-for-wrong-number-of-arguments-error Add `mrb_num_args_error()` for "wrong number of arguments" error
2020-01-01Revert "SHARED string is not required when sharing POOL string" (75949836)KOBAYASHI Shuji
Because literal pool may be released by GC. #### Example: ```ruby s1 = eval('"abcdefghijklmnopqrstuvwxyz01"') GC.start p s1 #=> "\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00\x90\x03\x00stuvwxyz01" ```
2020-01-01Merge pull request #4918 from dearblue/sync-varsYukihiro "Matz" Matsumoto
Integrate `i` and `arg_i` in `mrb_get_args()`
2020-01-01Integrate `i` and `arg_i` in `mrb_get_args()`dearblue
The behavior of these two variables is the same.
2020-01-01Do not include `stdint.h` before `mruby.h`; ref #4750dearblue
2019-12-25Fix potentially use of wrong method cacheKOBAYASHI Shuji
#### Example (with `MRB_METHOD_CACHE`) ```ruby GC.start c = Class.new p c #=> #<Class:0x7fd6a180e790> c.new #=> cache `c.new` c = nil GC.start #=> `c` is GCed r = Range.dup p r #=> #<Class:0x7fd6a180e790> # [same pointer as `c`] r.new(2, 3) #=> ArgumentError: 'initialize': # wrong number of arguments (2 for 0) # [`c.new` is called instead of `r.new`] ``` #### Cause An entry of method cache is identified by class pointer and method id. However, reusing memory after GC may create a class with the same pointer as the cached class. #### Treatment Cleared method caches of the class when the class is GCed.
2019-12-20Fix potentially crash in `%n` of `mrb_vformat()` with 64-bit `int`KOBAYASHI Shuji
If `mrb_sym` is smaller than `int`, it is promoted to `int`.
2019-12-18Simplify `print_backtrace()`KOBAYASHI Shuji
2019-12-18Merge pull request #4875 from ↵Yukihiro "Matz" Matsumoto
shuujii/remove-location-info-from-Exception-inspect Remove location info from `Exception#inspect`
2019-12-17Refine output of `mrb_print_error()`KOBAYASHI Shuji
The following improvements are made according to Ruby's behavior: - Match location number to index. - Remove duplicate most recent call output. - Fix that first call is not output when array (unpacked) backtrace. ### Example ```ruby def a; raise "error!" end def b; a end begin b rescue => e e.backtrace if ARGV[0] == "unpack" # unpack backtrace raise e end ``` #### Before this patch: ``` $ bin/mruby example.rb unpack trace (most recent call last): [0] example.rb:2:in b [1] example.rb:1:in a example.rb:1: error! (RuntimeError) ``` #### After this patch: ``` $ bin/mruby example.rb unpack trace (most recent call last): [2] example.rb:4 [1] example.rb:2:in b example.rb:1:in a: error! (RuntimeError) ```
2019-12-16Remove unneeded null checks to `struct backtrace_location::filename`KOBAYASHI Shuji
`struct backtrace_location` is created only in `each_backtrace()`, and the `filename` field will never be null (it will be `(unknown)` if null).
2019-12-14Remove location info from `Exception#inspect`KOBAYASHI Shuji
Because location info (file name and line number) is kept in the backtrace, it should not be kept in the result of `inspect` (and the exception object itself), I think. ### Example ```ruby # example.rb begin raise "err" rescue => e p e end ``` #### Before this patch: ``` $ bin/mruby example.rb example.rb:2: err (RuntimeError) ``` #### After this patch: ``` $ bin/mruby example.rb err (RuntimeError) ```
2019-12-14Remove module only methods from classdearblue
The `#prepend_features` and `#module_function` methods are not haves for class objects.
2019-12-13Fix arguments check to `Array#each`KOBAYASHI Shuji
#### Before this patch: ``` $ mruby -e '[].each(1){}' #=> no error ``` #### After this patch: ``` $ mruby -e '[].each(1){}' #=> ArgumentError: wrong number of arguments ```
2019-12-12Add `mrb_num_args_error()` for "wrong number of arguments" errorKOBAYASHI Shuji
To unify the style of messages.
2019-12-11Fix behavior of `Kernel#Integer` to numbers ending with `_` and spacesKOBAYASHI Shuji
#### Before this patch: ```ruby Integer("1_ ") #=> 1 ``` #### After this patch (same as Ruby): ```ruby Integer("1_ ") #=> ArgumentError ```
2019-12-10Fix behavior of `String#to_i`/`Kernel#Integer` to numbers starting with `_`KOBAYASHI Shuji
#### Before this patch: ```ruby Integer("_1") #=> 1 "_1".to_i #=> 1 ``` #### After this patch (same as Ruby): ```ruby Integer("_1") #=> ArgumentError "_1".to_i #=> 0 ```
2019-12-10Merge pull request #4858 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-that-String-to_f-accepts-consecutive-_-as-a-numeric-expression Fix that `String#to_f` accepts consecutive `_` as a numeric expression
2019-12-09Fix that `String#to_f` accepts consecutive `_` as a numeric expressionKOBAYASHI Shuji
Consecutive `_` is not allowed as a numeric expression: 1_2__3 #=> SyntaxError Float("1_2__3") #=> ArgumentError Integer("1_2__3") #=> ArgumentError "1_2__3".to_i #=> 12 But `String#to_f` accept it, so I fixed the issue. Before this patch: "1_2__3".to_f #=> 123 After this patch: "1_2__3".to_f #=> 12
2019-12-09Fix `mrb_get_argv()` to return array pointer every time; fix #4832Yukihiro "Matz" Matsumoto
2019-12-09Merge pull request #4855 from dearblue/kwargs-uninitYukihiro "Matz" Matsumoto
Fix keyword arguments not be obtained with `mrb_get_args()`; Fix #4754
2019-12-08Fix the error message of `Kernel#Float`KOBAYASHI Shuji
#### Before this patch: ``` $ bin/mruby -e 'Float("1_a")' -e:1: invalid string for float(a) (ArgumentError) ``` #### After this patch: ``` $ bin/mruby -e 'Float("1_a")' -e:1: invalid string for float("1_a") (ArgumentError) ```
2019-12-07Fix keyword arguments not be obtained with `mrb_get_args()`; Fix #4754dearblue
If ":" is after "|" and there is no "?" or "*", the keyword argument could not be obtained and it was not initialized with `undef`. For example: "|oo:"
2019-12-04Refine `mrb_alloca()`KOBAYASHI Shuji
* The allocated memory is guaranteed to be aligned for any data type (it was not guaranteed when string type is embed). * Make allocation size exactly specified size (does not allocate space for a null byte).
2019-11-27Merge pull request #4837 from shuujii/add-assertion-to-RVALUE-sizeYukihiro "Matz" Matsumoto
Add assertion to `RVALUE` size
2019-11-23Rename `BITSIZE` to `BIT` and `BIT` to `BIT_POS` for consistencyKOBAYASHI Shuji
The bit width terminology is unified to `BIT` according to `MRB_INT_BIT` and `CHAR_BIT`. Also the bit position terminology is unified to `BIT_POS`.
2019-11-23Add assertion to `RVALUE` sizeKOBAYASHI Shuji
2019-11-21Introduce `mrb_ssize` type for buffer size on memory; ref #4483KOBAYASHI Shuji
Previously, `mrb_int` was used as the type that represents the buffer size on memory, but the sizes of `RString` and `RArray` exceed 6 words when `MRB_INT64` is enabled on 32-bit CPU. I don't think it is necessary to be able to represent the buffer size on memory that exceeds the virtual address space. Therefore, for this purpose, introduce `mrb_ssize` which doesn't exceed the sizes of `mrb_int` and pointer. I think all `mrb_int` used for this purpose should be changed to `mrb_ssize`, but currently only the members of the structures (`RString`, `mrb_shared_string`, `RArray` and `mrb_shared_array`) are changed.
2019-11-19Refactor `mrb_string_value_cstr`KOBAYASHI Shuji
- Keep `MRB_STR_ASCII` flag. - Avoid a string object creation.
2019-11-18Merge pull request #4825 from shuujii/fix-argument-specs-to-KernelYukihiro "Matz" Matsumoto
Fix argument specs to `Kernel`
2019-11-16Revert "Implement Ruby2.7's frozen strings from `Symbol#to_s`"KOBAYASHI Shuji
This feature was reverted from Ruby 2.7.
2019-11-15Fix argument specs to `Kernel`KOBAYASHI Shuji
2019-11-13Revert a76dc04 to resolve #4820Yukihiro "Matz" Matsumoto
2019-11-11Fix argument specs to `Integer`KOBAYASHI Shuji
2019-11-08Avoid unnecessary `Symbol#to_s` call; fix #4812Yukihiro "Matz" Matsumoto