Skip to content

Commit

Permalink
[string] Made Parrot_str_byte_length() check for a NULL STRING pointe…
Browse files Browse the repository at this point in the history
…r because

we don't have STRINGNULL yet.  Fixes TT #1136, reported by Will Coleda.

git-svn-id: https://svn.parrot.org/parrot/trunk@42173 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
chromatic committed Oct 30, 2009
1 parent 5446253 commit 5bc1518
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions include/parrot/string_funcs.h
Expand Up @@ -77,8 +77,7 @@ INTVAL Parrot_str_boolean(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))

PARROT_EXPORT
PARROT_PURE_FUNCTION
UINTVAL Parrot_str_byte_length(SHIM_INTERP, ARGIN(const STRING *s))
__attribute__nonnull__(2);
UINTVAL Parrot_str_byte_length(SHIM_INTERP, ARGIN_NULLOK(const STRING *s));

PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
Expand Down Expand Up @@ -561,8 +560,7 @@ STRING* Parrot_str_from_uint(PARROT_INTERP,
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_str_boolean __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_str_byte_length __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(s))
#define ASSERT_ARGS_Parrot_str_byte_length __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
#define ASSERT_ARGS_Parrot_str_change_charset __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_str_change_encoding __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
Expand Down
4 changes: 2 additions & 2 deletions src/string/api.c
Expand Up @@ -898,11 +898,11 @@ Returns the number of characters in the specified Parrot string.
PARROT_EXPORT
PARROT_PURE_FUNCTION
UINTVAL
Parrot_str_byte_length(SHIM_INTERP, ARGIN(const STRING *s))
Parrot_str_byte_length(SHIM_INTERP, ARGIN_NULLOK(const STRING *s))
{
ASSERT_ARGS(Parrot_str_byte_length)

return s->strlen;
return s ? s->strlen : 0;
}


Expand Down

0 comments on commit 5bc1518

Please sign in to comment.