Browse files

Validate input before it goes to functions that requires it

  • Loading branch information...
1 parent 03b8622 commit 7d4ca20e9956d36bb2f5fb2c8866332801f8b870 Nikolai Weibull committed Apr 7, 2013
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),

0 comments on commit 7d4ca20

Please sign in to comment.