jdk/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c
changeset 16735 73b1a1971a76
parent 14414 f338be3ef659
child 23335 25ed8994b97f
equal deleted inserted replaced
16734:da1901d79073 16735:73b1a1971a76
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3  */
     3  */
     4 
     4 
     5 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
     5 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
     6  *
     6  *
     7  * Redistribution and use in  source and binary forms, with or without
     7  * Redistribution and use in  source and binary forms, with or without
   102 #endif /* DEBUG */
   102 #endif /* DEBUG */
   103 
   103 
   104     if (hModule == NULL) {
   104     if (hModule == NULL) {
   105         systemErrorMessage = dlerror();
   105         systemErrorMessage = dlerror();
   106         exceptionMessage = (char *) malloc(sizeof(char) * (strlen(systemErrorMessage) + strlen(libraryNameStr) + 1));
   106         exceptionMessage = (char *) malloc(sizeof(char) * (strlen(systemErrorMessage) + strlen(libraryNameStr) + 1));
       
   107         if (exceptionMessage == NULL) {
       
   108             throwOutOfMemoryError(env, 0);
       
   109             return;
       
   110         }
   107         strcpy(exceptionMessage, systemErrorMessage);
   111         strcpy(exceptionMessage, systemErrorMessage);
   108         strcat(exceptionMessage, libraryNameStr);
   112         strcat(exceptionMessage, libraryNameStr);
   109         throwIOException(env, exceptionMessage);
   113         throwIOException(env, exceptionMessage);
   110         (*env)->ReleaseStringUTFChars(env, jPkcs11ModulePath, libraryNameStr);
   114         (*env)->ReleaseStringUTFChars(env, jPkcs11ModulePath, libraryNameStr);
   111         free(exceptionMessage);
   115         free(exceptionMessage);
   132 
   136 
   133     /*
   137     /*
   134      * Get function pointers to all PKCS #11 functions
   138      * Get function pointers to all PKCS #11 functions
   135      */
   139      */
   136     moduleData = (ModuleData *) malloc(sizeof(ModuleData));
   140     moduleData = (ModuleData *) malloc(sizeof(ModuleData));
       
   141     if (moduleData == NULL) {
       
   142         dlclose(hModule);
       
   143         throwOutOfMemoryError(env, 0);
       
   144         return;
       
   145     }
   137     moduleData->hModule = hModule;
   146     moduleData->hModule = hModule;
   138     moduleData->applicationMutexHandler = NULL;
   147     moduleData->applicationMutexHandler = NULL;
   139     rv = (C_GetFunctionList)(&(moduleData->ckFunctionListPtr));
   148     rv = (C_GetFunctionList)(&(moduleData->ckFunctionListPtr));
   140     globalPKCS11ImplementationReference = (*env)->NewGlobalRef(env, obj);
   149     globalPKCS11ImplementationReference = (*env)->NewGlobalRef(env, obj);
   141     putModuleEntry(env, globalPKCS11ImplementationReference, moduleData);
   150     putModuleEntry(env, globalPKCS11ImplementationReference, moduleData);