Skip to content

Commit bdc2e56

Browse files
author
Stefan Mücke
committed
Fix bug in VARDESC and TYPEDESC (#1644)
1 parent d1bef49 commit bdc2e56

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Features
1212
Bug Fixes
1313
---------
1414
* [#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)
15+
* [#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)
1516

1617
Release 5.15.0
1718
==============

contrib/platform/src/com/sun/jna/platform/win32/OaIdl.java

+26-11
Original file line numberDiff line numberDiff line change
@@ -1398,14 +1398,10 @@ public static class ByReference extends _VARDESC implements
13981398
public VARIANT.ByReference lpvarValue;
13991399

14001400
public _VARDESC() {
1401-
setType("lpvarValue");
1402-
this.read();
14031401
}
14041402

14051403
public _VARDESC(Pointer pointer) {
14061404
super(pointer);
1407-
setType("lpvarValue");
1408-
this.read();
14091405
}
14101406

14111407
/**
@@ -1431,9 +1427,15 @@ public VARDESC() {
14311427

14321428
public VARDESC(Pointer pointer) {
14331429
super(pointer);
1434-
this._vardesc.setType("lpvarValue");
14351430
this.read();
14361431
}
1432+
1433+
@Override
1434+
public void read() {
1435+
readField("varkind");
1436+
this._vardesc.setType(varkind.value == VARKIND.VAR_CONST ? "lpvarValue" : "oInst");
1437+
super.read();
1438+
}
14371439
}
14381440

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

16561658
public _TYPEDESC() {
1657-
this.setType("hreftype");
1658-
this.read();
16591659
}
16601660

16611661
public _TYPEDESC(Pointer pointer) {
16621662
super(pointer);
1663-
this.setType("hreftype");
1664-
this.read();
16651663
}
16661664

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

16891687
public TYPEDESC() {
1690-
this.read();
16911688
}
16921689

16931690
public TYPEDESC(Pointer pointer) {
16941691
super(pointer);
1695-
this.read();
16961692
}
16971693

16981694
public TYPEDESC(_TYPEDESC _typedesc, VARTYPE vt) {
16991695
this._typedesc = _typedesc;
17001696
this.vt = vt;
17011697
}
1698+
1699+
@Override
1700+
public void read() {
1701+
readField("vt");
1702+
switch (vt.intValue()) {
1703+
case Variant.VT_PTR:
1704+
case Variant.VT_SAFEARRAY:
1705+
_typedesc.setType("lptdesc");
1706+
break;
1707+
case Variant.VT_CARRAY:
1708+
_typedesc.setType("lpadesc");
1709+
break;
1710+
case Variant.VT_USERDEFINED:
1711+
default:
1712+
_typedesc.setType("hreftype");
1713+
break;
1714+
}
1715+
super.read();
1716+
}
17021717
}
17031718

17041719
@FieldOrder({"dwReserved", "wIDLFlags"})

0 commit comments

Comments
 (0)