You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sc...@apache.org on 2015/01/08 15:57:07 UTC
svn commit: r1650304 - /tomcat/native/trunk/native/src/jnilib.c
Author: schultz
Date: Thu Jan 8 14:57:07 2015
New Revision: 1650304
URL: http://svn.apache.org/r1650304
Log:
Remove zero-boundary-check on String length argument, as this argument is unsigned and can therefore never be less than zero.
Removes a compiler warning and simplifies the code a bit.
Modified:
tomcat/native/trunk/native/src/jnilib.c
Modified: tomcat/native/trunk/native/src/jnilib.c
URL: http://svn.apache.org/viewvc/tomcat/native/trunk/native/src/jnilib.c?rev=1650304&r1=1650303&r2=1650304&view=diff
==============================================================================
--- tomcat/native/trunk/native/src/jnilib.c (original)
+++ tomcat/native/trunk/native/src/jnilib.c Thu Jan 8 14:57:07 2015
@@ -139,18 +139,15 @@ jstring tcn_new_stringn(JNIEnv *env, con
{
jstring result;
jbyteArray bytes = 0;
- size_t len = l;
if (!str)
return NULL;
if ((*env)->EnsureLocalCapacity(env, 2) < 0) {
return NULL; /* out of memory error */
}
- if (l < 0)
- len = strlen(str);
- bytes = (*env)->NewByteArray(env, (jsize)len);
+ bytes = (*env)->NewByteArray(env, l);
if (bytes != NULL) {
- (*env)->SetByteArrayRegion(env, bytes, 0, (jint)len, (jbyte *)str);
+ (*env)->SetByteArrayRegion(env, bytes, 0, l, (jbyte *)str);
result = (*env)->NewObject(env, jString_class, jString_init, bytes);
(*env)->DeleteLocalRef(env, bytes);
return result;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org