Check size before accesing empty vectors data ptr
@@ -78,15 +78,20 @@ cpdef intptr_t createProgram(unicode src, unicode name, headers,
cdef int num_headers = len(headers)
cdef vector.vector[const char*] header_vec
cdef vector.vector[const char*] include_name_vec
+ cdef const char** header_vec_ptr = NULL
+ cdef const char** include_name_vec_ptr = NULL
+ assert num_headers == len(include_names)
for i in headers:
header_vec.push_back(<const char*>i)
for i in include_names:
include_name_vec.push_back(<const char*>i)
-
+ if num_headers > 0:
+ header_vec_ptr = header_vec.data()
+ include_name_vec_ptr = include_name_vec.data()
with nogil:
status = nvrtcCreateProgram(
- &prog, src_ptr, name_ptr, num_headers, header_vec.data(),
- include_name_vec.data())
+ &prog, src_ptr, name_ptr, num_headers, header_vec_ptr,
+ include_name_vec_ptr)
check_status(status)
return <intptr_t>prog
@@ -102,12 +107,14 @@ cpdef compileProgram(intptr_t prog, options):
cdef int option_num = len(options)
cdef vector.vector[const char*] option_vec
cdef option_list = [opt.encode() for opt in options]
+ cdef const char** option_vec_ptr = NULL
for i in option_list:
option_vec.push_back(<const char*>i)
-
+ if option_num > 0:
+ option_vec_ptr = option_vec.data()
with nogil:
status = nvrtcCompileProgram(<Program>prog, option_num,
- option_vec.data())
+ option_vec_ptr)
check_status(status)
