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

Fix bug in VARDESC (#1644) #1645

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Features
Bug Fixes
---------
* [#1618](https://github.com/java-native-access/jna/issues/1618): Fix calls to jnidispatch on Android with 16KB page size - [@Thomyrock](https://github.com/Thomyrock)
* [#1644](https://github.com/java-native-access/jna/issues/1644): Fix bug in VARDESC and TYPEDESC causing an illegal memory access - [@stmuecke](https://github.com/stmuecke)

Release 5.15.0
==============
Expand Down
37 changes: 26 additions & 11 deletions contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1398,14 +1398,10 @@ public static class ByReference extends _VARDESC implements
public VARIANT.ByReference lpvarValue;

public _VARDESC() {
setType("lpvarValue");
this.read();
}

public _VARDESC(Pointer pointer) {
super(pointer);
setType("lpvarValue");
this.read();
}

/**
Expand All @@ -1431,9 +1427,15 @@ public VARDESC() {

public VARDESC(Pointer pointer) {
super(pointer);
this._vardesc.setType("lpvarValue");
this.read();
}

@Override
public void read() {
readField("varkind");
this._vardesc.setType(varkind.value == VARKIND.VAR_CONST ? "lpvarValue" : "oInst");
super.read();
}
}

@FieldOrder({"tdesc", "_elemdesc"})
Expand Down Expand Up @@ -1654,14 +1656,10 @@ public static class _TYPEDESC extends Union {
public HREFTYPE hreftype;

public _TYPEDESC() {
this.setType("hreftype");
this.read();
}

public _TYPEDESC(Pointer pointer) {
super(pointer);
this.setType("hreftype");
this.read();
}

public TYPEDESC.ByReference getLptdesc() {
Expand All @@ -1687,18 +1685,35 @@ public HREFTYPE getHreftype() {
public VARTYPE vt;

public TYPEDESC() {
this.read();
}

public TYPEDESC(Pointer pointer) {
super(pointer);
this.read();
}

public TYPEDESC(_TYPEDESC _typedesc, VARTYPE vt) {
this._typedesc = _typedesc;
this.vt = vt;
}

@Override
public void read() {
readField("vt");
switch (vt.intValue()) {
case Variant.VT_PTR:
case Variant.VT_SAFEARRAY:
_typedesc.setType("lptdesc");
break;
case Variant.VT_CARRAY:
_typedesc.setType("lpadesc");
break;
case Variant.VT_USERDEFINED:
default:
_typedesc.setType("hreftype");
break;
}
super.read();
}
}

@FieldOrder({"dwReserved", "wIDLFlags"})
Expand Down
Loading