Skip to content

Commit

Permalink
Fix bug in VARDESC and TYPEDESC (#1644)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Mücke committed Dec 15, 2024
1 parent 3befd7f commit 2c7161a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Features

Bug Fixes
---------
* [#1644](https://github.com/java-native-access/jna/issues/1644): Fix bug in VARDESC causing an illegal memory access - [@stmuecke](https://github.com/stmuecke)

Release 5.15.0
==============
Expand Down
36 changes: 25 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,34 @@ 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 :
_typedesc.setType("hreftype");
break;
}
super.read();
}
}

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

0 comments on commit 2c7161a

Please sign in to comment.