Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Validate input before it goes to functions that requires it

  • Loading branch information...
commit 7d4ca20e9956d36bb2f5fb2c8866332801f8b870 1 parent 03b8622
Nikolai Weibull authored
Showing with 6 additions and 0 deletions.
  1. +6 −0 ext/u/rb_u.c
View
6 ext/u/rb_u.c
@@ -108,6 +108,8 @@ _rb_u_string_test(VALUE self,
{
const struct rb_u_string *string = RVAL2USTRING(self);
+ rb_u_validate(USTRING_STR(string), USTRING_LENGTH(string));
+
size_t nfd_length;
char *nfd = u_normalize_n(USTRING_STR(string),
USTRING_LENGTH(string),
@@ -139,6 +141,8 @@ _rb_u_string_test_in_locale(int argc, VALUE *argv, VALUE self,
const struct rb_u_string *string = RVAL2USTRING(self);
+ rb_u_validate(USTRING_STR(string), USTRING_LENGTH(string));
+
size_t nfd_length;
char *nfd = u_normalize_n(USTRING_STR(string),
USTRING_LENGTH(string),
@@ -173,6 +177,8 @@ _rb_u_string_case_in_locale(int argc, VALUE *argv, VALUE self,
const struct rb_u_string *string = RVAL2USTRING(self);
+ rb_u_validate(USTRING_STR(string), USTRING_LENGTH(string));
+
size_t length;
char *cased = case_in_locale_n(USTRING_STR(string),
USTRING_LENGTH(string),
Please sign in to comment.
Something went wrong with that request. Please try again.