mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
string.c (check_null_byte): str may point NULL buffer; ref #6067
This commit is contained in:
+2
-1
@@ -246,7 +246,8 @@ str_modify_keep_ascii(mrb_state *mrb, struct RString *s)
|
||||
static void
|
||||
check_null_byte(mrb_state *mrb, struct RString *str)
|
||||
{
|
||||
if (memchr(RSTR_PTR(str), '\0', RSTR_LEN(str))) {
|
||||
const char *p = RSTR_PTR(str);
|
||||
if (p && memchr(p, '\0', RSTR_LEN(str))) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "string contains null byte");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user