src/windows/native/java/lang/ProcessEnvironment_md.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2003, 2014 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 30,43 **** static jstring environmentBlock9x(JNIEnv *env) { int i; ! jmethodID String_init_ID = ! (*env)->GetMethodID(env, JNU_ClassString(env), "<init>", "([B)V"); jbyteArray bytes; ! jbyte *blockA = (jbyte *) GetEnvironmentStringsA(); if (blockA == NULL) { /* Both GetEnvironmentStringsW and GetEnvironmentStringsA * failed. Out of memory is our best guess. */ JNU_ThrowOutOfMemoryError(env, "GetEnvironmentStrings failed"); return NULL; --- 30,50 ---- static jstring environmentBlock9x(JNIEnv *env) { int i; ! jmethodID String_init_ID; jbyteArray bytes; ! jbyte *blockA; ! jclass string_class; ! ! string_class= JNU_ClassString(env); ! CHECK_NULL_RETURN(string_class, NULL); ! String_init_ID = ! (*env)->GetMethodID(env, string_class, "<init>", "([B)V"); ! CHECK_NULL_RETURN(String_init_ID); ! blockA = (jbyte *) GetEnvironmentStringsA(); if (blockA == NULL) { /* Both GetEnvironmentStringsW and GetEnvironmentStringsA * failed. Out of memory is our best guess. */ JNU_ThrowOutOfMemoryError(env, "GetEnvironmentStrings failed"); return NULL;
*** 47,60 **** legitimately consist of a single "\0". */ for (i = 0; blockA[i];) while (blockA[i++]) ; ! if ((bytes = (*env)->NewByteArray(env, i)) == NULL) return NULL; (*env)->SetByteArrayRegion(env, bytes, 0, i, blockA); FreeEnvironmentStringsA(blockA); ! return (*env)->NewObject(env, JNU_ClassString(env), String_init_ID, bytes); } /* Returns a Windows style environment block, discarding final trailing NUL */ JNIEXPORT jstring JNICALL --- 54,70 ---- legitimately consist of a single "\0". */ for (i = 0; blockA[i];) while (blockA[i++]) ; ! if ((bytes = (*env)->NewByteArray(env, i)) == NULL) { ! FreeEnvironmentStringsA(blockA); ! return NULL; ! } (*env)->SetByteArrayRegion(env, bytes, 0, i, blockA); FreeEnvironmentStringsA(blockA); ! return (*env)->NewObject(env, string_class, String_init_ID, bytes); } /* Returns a Windows style environment block, discarding final trailing NUL */ JNIEXPORT jstring JNICALL