Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advapi32Util.registryGetValues() returns no results if the key contains an empty REG_* value #135

Closed
danwi opened this issue Oct 8, 2012 · 2 comments

Comments

@danwi
Copy link
Contributor

danwi commented Oct 8, 2012

(Related to #116 which only adressed REG_BINARY values.)

If you create an empty value of one of the following types and try to read the values using Advapi32Util.registryGetValues() you will get an exception:

REG_SZ
REG_EXPAND_SZ
REG_MULTI_SZ
REG_NONE

The Exception:
java.lang.IllegalArgumentException: Allocation size must be greater than zero
at com.sun.jna.Memory.(Memory.java:84)
at com.sun.jna.platform.win32.Advapi32Util.registryGetValues(Advapi32Util.java:1270)
at com.sun.jna.platform.win32.Advapi32Util.registryGetValues(Advapi32Util.java:1332)
[...]

I have written unit test and code to solve the problem in a stubbed environment (I haven't had the time to get the full build environment for jna up and running yet), I will provide a pull request with the fix as soon as I've applied the changes from my stubbed environment to my real jna repo clone.

Question: should unit tests and the fix be checked in as two separate commits or as one commit?

@twall
Copy link
Contributor

twall commented Oct 8, 2012

single commit is fine.

danwi added a commit to danwi/jna that referenced this issue Oct 8, 2012
…ty values)

With this fix it is possible to read values from registry of the following
types even when the size of the value is 0:

REG_SZ
REG_EXPAND_SZ
REG_MULTI_SZ
REG_NONE
REG_BINARY (fixed by earlier committer)

Advapi32UtilTest updated with unit test triggering the bug.
dblock added a commit that referenced this issue Oct 8, 2012
Add fix for issue #135 in Advapi32Util (reading empty values)
@dblock
Copy link
Member

dblock commented Oct 8, 2012

Merged, thank you for contributing.

@dblock dblock closed this as completed Oct 8, 2012
danwi added a commit to danwi/jna that referenced this issue Oct 8, 2012
dblock added a commit that referenced this issue Oct 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants