> On 8 Jan 2020, at 05:12, Anuraag Agrawal <anura...@gmail.com> wrote: > > Hi Chris, > > Happy new year - sorry for the long delay. I have made an updated patch > fixing the comment (missing comma), bumping MAX_STR_LEN, and tweaking the > exception behavior. > > Basically, as you pointed out loadDNSConfig itself does not throw any > exception. The getAdapters function will throw a) OutOfMemoryError if native > memory allocation failed or b) Error if the Windows SDK function randomly > failed. I have gone ahead and added code to check the exception thrown when > getAdapters failed and propagate it if it is OOME or clear it otherwise. This > should be the same behavior as the old version of loadDNSConfig.
... > - if (adapterP) { > - free(adapterP); > + free(adapters); > + } else { > + th = (*env)->ExceptionOccurred(env); > + if (th != NULL) { > + // We only throw errors if not able to allocate memory, otherwise > + // ignore ones related to Windows API usage itself. > + (*env)->ExceptionClear(env); > + if ((*env)->IsInstanceOf(env, th, outOfMemoryErrCl)) { > + (*env)->Throw(env, th); > + return STS_ERROR; > + } > + } I think that it would be preferable to NOT clear the pending exception, and just allow it to propagate up. -Chris.