# HG changeset patch # User igerasim # Date 1401402800 -14400 # Node ID 256eb760e01f1f2f7d259fd3f4ad046fbef5727a # Parent 97bddac495b78478fda236f311f9507afcdb39d5 8044342: build failure on Windows noticed with recent smartcardio fix Reviewed-by: valeriep diff -r 97bddac495b7 -r 256eb760e01f jdk/src/share/native/sun/security/smartcardio/pcsc.c --- a/jdk/src/share/native/sun/security/smartcardio/pcsc.c Thu May 29 15:50:36 2014 +0100 +++ b/jdk/src/share/native/sun/security/smartcardio/pcsc.c Fri May 30 02:33:20 2014 +0400 @@ -122,28 +122,35 @@ /** * Convert a multi string to a java string array, */ -jobjectArray pcsc_multi2jstring(JNIEnv *env, char *spec, DWORD size) { +jobjectArray pcsc_multi2jstring(JNIEnv *env, char *spec) { jobjectArray result; jclass stringClass; - char* tab[PCSCLITE_MAX_READERS_CONTEXTS]; + char *cp, **tab = NULL; jstring js; int cnt = 0; - DWORD i; + + cp = spec; + while (*cp != 0) { + cp += (strlen(cp) + 1); + ++cnt; + } - if (spec && size) { - spec[size - 1] = 0; - for (i = 0; i < size && spec[i]; ++i) { - tab[cnt++] = spec + i; - if (cnt == PCSCLITE_MAX_READERS_CONTEXTS) { - break; - } - for (++i; i < size && spec[i]; ++i) { - } - } + tab = (char **)malloc(cnt * sizeof(char *)); + if (tab == NULL) { + throwOutOfMemoryError(env, NULL); + return NULL; + } + + cnt = 0; + cp = spec; + while (*cp != 0) { + tab[cnt++] = cp; + cp += (strlen(cp) + 1); } stringClass = (*env)->FindClass(env, "java/lang/String"); if (stringClass == NULL) { + free(tab); return NULL; } @@ -152,15 +159,18 @@ while (cnt-- > 0) { js = (*env)->NewStringUTF(env, tab[cnt]); if ((*env)->ExceptionCheck(env)) { + free(tab); return NULL; } (*env)->SetObjectArrayElement(env, result, cnt, js); if ((*env)->ExceptionCheck(env)) { + free(tab); return NULL; } (*env)->DeleteLocalRef(env, js); } } + free(tab); return result; } @@ -195,7 +205,7 @@ dprintf1("-String: %s\n", mszReaders); } - result = pcsc_multi2jstring(env, mszReaders, size); + result = pcsc_multi2jstring(env, mszReaders); free(mszReaders); return result; }