# HG changeset patch # User valeriep # Date 1365131147 25200 # Node ID 73b1a1971a76d3e9e049cf9a51e436379bb63fbe # Parent da1901d79073edcd04f3ea3f01e65c2ba4edc332 7155720: PKCS11 minor issues in native code Summary: Added OOM handling to address the two issues found by parfait. Reviewed-by: weijun diff -r da1901d79073 -r 73b1a1971a76 jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c --- a/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c Thu Apr 04 15:39:17 2013 -0700 +++ b/jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c Thu Apr 04 20:05:47 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 2002 Graz University of Technology. All rights reserved. @@ -104,6 +104,10 @@ if (hModule == NULL) { systemErrorMessage = dlerror(); exceptionMessage = (char *) malloc(sizeof(char) * (strlen(systemErrorMessage) + strlen(libraryNameStr) + 1)); + if (exceptionMessage == NULL) { + throwOutOfMemoryError(env, 0); + return; + } strcpy(exceptionMessage, systemErrorMessage); strcat(exceptionMessage, libraryNameStr); throwIOException(env, exceptionMessage); @@ -134,6 +138,11 @@ * Get function pointers to all PKCS #11 functions */ moduleData = (ModuleData *) malloc(sizeof(ModuleData)); + if (moduleData == NULL) { + dlclose(hModule); + throwOutOfMemoryError(env, 0); + return; + } moduleData->hModule = hModule; moduleData->applicationMutexHandler = NULL; rv = (C_GetFunctionList)(&(moduleData->ckFunctionListPtr));