Skip to content

Commit 021a799

Browse files
committed
JavaCL: avoid some NPEs in CLProgram.getProgramBuildInfo (issue #479)
1 parent 66d95ea commit 021a799

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Core/src/main/velocity/com/nativelibs4java/opencl/CLProgram.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,9 @@ private String getProgramBuildInfo(long pgm, long deviceId) {
699699
Pointer<SizeT> pLen = allocateSizeT();
700700
error(CL.clGetProgramBuildInfo(pgm, deviceId, CL_PROGRAM_BUILD_LOG, 0, 0, getPeer(pLen)));
701701
long len = pLen.getSizeT();
702+
if (len == 0) {
703+
return null;
704+
}
702705
Pointer<?> buffer = allocateBytes(len);
703706
error(CL.clGetProgramBuildInfo(pgm, deviceId, CL_PROGRAM_BUILD_LOG, len, getPeer(buffer), 0));
704707
String s = buffer.getCString();
@@ -710,12 +713,12 @@ private Set<String> getProgramBuildInfo(long pgm, Pointer<SizeT> deviceIds) {
710713
Set<String> errs = new HashSet<String>();
711714
if (deviceIds == null) {
712715
String s = getProgramBuildInfo(pgm, 0);
713-
if (s.length() > 0)
716+
if (s != null && s.length() > 0)
714717
errs.add(s);
715718
} else {
716719
for (SizeT device : deviceIds) {
717720
String s = getProgramBuildInfo(pgm, device.longValue());
718-
if (s.length() > 0)
721+
if (s != null && s.length() > 0)
719722
errs.add(s);
720723
}
721724
}

0 commit comments

Comments
 (0)