diff options
| author | cubicdaiya <[email protected]> | 2014-02-28 02:07:09 +0900 |
|---|---|---|
| committer | cubicdaiya <[email protected]> | 2014-02-28 02:07:09 +0900 |
| commit | 8336072e865d9fbe03645b95ab2ea37d84ecd65d (patch) | |
| tree | 716f4c5e03145c913e57d3ef95cb59210c356809 /src/string.c | |
| parent | 25822f2430eb31ecf012264a53f6a82fc7d6ad30 (diff) | |
| download | mruby-8336072e865d9fbe03645b95ab2ea37d84ecd65d.tar.gz mruby-8336072e865d9fbe03645b95ab2ea37d84ecd65d.zip | |
fix SEGV bug for mrb_str_new_static
mrb_str_new_static causes seg-fault when 3rd argument is negative.
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c index 8a9ed8a24..aa1afec47 100644 --- a/src/string.c +++ b/src/string.c @@ -256,6 +256,9 @@ mrb_value mrb_str_new_static(mrb_state *mrb, const char *p, size_t len) { struct RString *s; + if ((mrb_int)len < 0) { + mrb_raise(mrb, E_ARGUMENT_ERROR, "negative string size (or size too big)"); + } s = mrb_obj_alloc_string(mrb); s->len = len; |
