summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/CLContext.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-22 04:07:14 +0200
committerMichael Bien <[email protected]>2010-04-22 04:07:14 +0200
commit2fc985f0cdc373cb3c78cc198e21dcc1ce5d961f (patch)
tree2b749169a2fc28c77f54260ca56a4f937d9f082d /src/com/jogamp/opencl/CLContext.java
parent5a6d1f0cd4da6582cca526e45964effa6c2b1419 (diff)
CLContext should not throw NPE in create(...) if a device or device type is null.
Diffstat (limited to 'src/com/jogamp/opencl/CLContext.java')
-rw-r--r--src/com/jogamp/opencl/CLContext.java16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/com/jogamp/opencl/CLContext.java b/src/com/jogamp/opencl/CLContext.java
index a50bf628..07b59d9e 100644
--- a/src/com/jogamp/opencl/CLContext.java
+++ b/src/com/jogamp/opencl/CLContext.java
@@ -160,7 +160,11 @@ public class CLContext extends CLObject implements CLResource {
if(devices != null && devices.length != 0) {
pb = PointerBuffer.allocateDirect(devices.length);
for (int i = 0; i < devices.length; i++) {
- pb.put(i, devices[i].ID);
+ CLDevice device = devices[i];
+ if(device == null) {
+ throw new IllegalArgumentException("device at index"+i+" was null.");
+ }
+ pb.put(i, device.ID);
}
}
long context = CLPlatform.getLowLevelCLInterface().clCreateContext(properties, pb, null, null, status);
@@ -463,13 +467,17 @@ public class CLContext extends CLObject implements CLResource {
}
protected static long toDeviceBitmap(Type[] deviceTypes) {
- long type = 0;
+ long bitmap = 0;
if (deviceTypes != null) {
for (int i = 0; i < deviceTypes.length; i++) {
- type |= deviceTypes[i].TYPE;
+ Type type = deviceTypes[i];
+ if(type == null) {
+ throw new IllegalArgumentException("Device type at index "+i+" was null.");
+ }
+ bitmap |= type.TYPE;
}
}
- return type;
+ return bitmap;
}
@Override