Skip to content

Commit 9162865

Browse files
Merge pull request #61 from lafoletc/GValueArray
Prevent exception in constructor of GValueArray
2 parents e56d0af + 3f6d27a commit 9162865

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/org/freedesktop/gstreamer/lowlevel/GValueAPI.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public String toString() {
232232
return GVALUE_API.g_strdup_value_contents(this);
233233
}
234234
}
235-
235+
236236
public static final class GValueArray extends com.sun.jna.Structure {
237237
public static final String GTYPE_NAME = "GValueArray";
238238

@@ -242,6 +242,7 @@ public static final class GValueArray extends com.sun.jna.Structure {
242242
public volatile int n_prealloced;
243243

244244
private boolean ownsMemory;
245+
private static final Pointer NO_MEMORY_POINTER = new Pointer(0);
245246

246247
public GValueArray() {
247248
this(0);
@@ -254,7 +255,8 @@ public GValueArray(int n_prealloced) {
254255

255256
public GValueArray(Pointer pointer) {
256257
super(pointer);
257-
n_values = pointer.getInt(0);
258+
if (pointer != Pointer.NULL && !NO_MEMORY_POINTER.equals(pointer))
259+
n_values = pointer.getInt(0);
258260
}
259261

260262
@SuppressWarnings("unused")

0 commit comments

Comments
 (0)