rb_str_crypt: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor.
This commit is contained in:
parent
a5ae9aebbc
commit
e3d821a36c
Notes:
git
2020-06-29 11:06:45 +09:00
6
string.c
6
string.c
@ -9645,8 +9645,7 @@ rb_str_crypt(VALUE str, VALUE salt)
|
||||
mustnot_wchar(str);
|
||||
mustnot_wchar(salt);
|
||||
if (RSTRING_LEN(salt) < 2) {
|
||||
short_salt:
|
||||
rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
|
||||
goto short_salt;
|
||||
}
|
||||
|
||||
s = StringValueCStr(str);
|
||||
@ -9677,6 +9676,9 @@ rb_str_crypt(VALUE str, VALUE salt)
|
||||
result = rb_str_new_cstr(res);
|
||||
CRYPT_END();
|
||||
return result;
|
||||
|
||||
short_salt:
|
||||
rb_raise(rb_eArgError, "salt too short (need >=2 bytes)");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user