[jdk9] (S) RFR: 8165463: Native implementation of sunmscapi should use operator new (nothrow) for allocations

Langer, Christoph christoph.langer at sap.com
Mon Sep 5 20:52:27 UTC 2016


Hi Ivan,

this looks like a good idea.

Maybe the pattern to do new (std::nothrow), then check for 0 and throw OOM is a good candidate for a Macro which would keep the code a bit more compact?

Best regards
Christoph

> -----Original Message-----
> From: security-dev [mailto:security-dev-bounces at openjdk.java.net] On Behalf
> Of Ivan Gerasimov
> Sent: Montag, 5. September 2016 21:53
> To: security-dev at openjdk.java.net
> Subject: [jdk9] (S) RFR: 8165463: Native implementation of sunmscapi should
> use operator new (nothrow) for allocations
> 
> Hello!
> 
> In the native layer of sunmscapi provider, for memory allocations the
> ::operator new() is used.
> In (a very unlikely) case of failure, it will raise a C++ exception of
> type bad_alloc, which is bad, as we don't have handling code.
> 
> One simple way to improve the situation would be to use ::operator new
> (std::nothrow), which will just return zero to indicate a failure
> instead of throwing an exception.
> Then we can (try to) throw a Java exception of type OutOfMemoryError.
> 
> Would you please help review the fix?
> 
> BUGURL: https://bugs.openjdk.java.net/browse/JDK-8165463
> WEBREV: http://cr.openjdk.java.net/~igerasim/8165463/00/webrev/
> 
> Comments/suggestions are very welcome.
> 
> With kind regards,
> Ivan
> 



More information about the security-dev mailing list