[ 
https://issues.apache.org/jira/browse/CRYPTO-141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16628077#comment-16628077
 ] 

Marcelo Vanzin commented on CRYPTO-141:
---------------------------------------

It might be a better idea to make the cleanup of the native context explicit, 
so that the Java side can do it when it knows it's safe.

> Errors in native code can leave Java wrappers in bad state
> ----------------------------------------------------------
>
>                 Key: CRYPTO-141
>                 URL: https://issues.apache.org/jira/browse/CRYPTO-141
>             Project: Commons Crypto
>          Issue Type: Bug
>          Components: Native
>            Reporter: Marcelo Vanzin
>            Priority: Major
>
> Currently, the Java side keeps a reference to the address of the EVP context, 
> and checks that it's not 0 before performing any operations.
> But if an error happens in native code, for example here in init():
> {code}
>   if (result == 0 && context != NULL) {
>     if (CONTEXT(ctx) != NULL) {
>       dlsym_EVP_CIPHER_CTX_cleanup(context);
>     } else {
>       dlsym_EVP_CIPHER_CTX_free(context);
>     }
>   }
> {code}
> The address known to the Java side will now be invalid, and if any native 
> method is now called the JVM will crash.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to