[pypy-commit] cffi default: (Reported by Felipe Cruz)
arigo
noreply at buildbot.pypy.org
Mon Jun 18 22:55:43 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r467:76e18a3da3f0
Date: 2012-06-18 22:55 +0200
http://bitbucket.org/cffi/cffi/changeset/76e18a3da3f0/
Log: (Reported by Felipe Cruz) Don't use strnlen(), use the more portable
memchr() instead.
diff --git a/c/_ffi_backend.c b/c/_ffi_backend.c
--- a/c/_ffi_backend.c
+++ b/c/_ffi_backend.c
@@ -994,8 +994,14 @@
cd->c_type->ct_itemdescr->ct_flags & CT_PRIMITIVE_CHAR) {
Py_ssize_t length;
- if (cd->c_type->ct_flags & CT_ARRAY)
- length = strnlen(cd->c_data, get_array_length(cd));
+ if (cd->c_type->ct_flags & CT_ARRAY) {
+ const char *start = cd->c_data;
+ const char *end;
+ length = get_array_length(cd);
+ end = (const char *)memchr(start, 0, length);
+ if (end != NULL)
+ length = end - start;
+ }
else
length = strlen(cd->c_data);
More information about the pypy-commit
mailing list