Skip to content

Commit dc5ab29

Browse files
committed
fixed rowptr integer width
1 parent df2f814 commit dc5ab29

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

python/liblinear/liblinear.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ def csr_to_problem_nojit(l, x_val, x_ind, x_rowptr, prob_val, prob_ind, prob_row
149149
def csr_to_problem(x, prob):
150150
# Extra space for termination node and (possibly) bias term
151151
x_space = prob.x_space = np.empty((x.nnz+x.shape[0]*2), dtype=feature_node)
152-
prob.rowptr = x.indptr.copy()
152+
# rowptr has to be a 64bit integer because it will later be used for pointer arithmetic,
153+
# which overflows when the added pointer points to an address that is numerically high.
154+
prob.rowptr = x.indptr.astype(np.int64, copy=True)
153155
prob.rowptr[1:] += 2*np.arange(1,x.shape[0]+1)
154156
prob_ind = x_space["index"]
155157
prob_val = x_space["value"]

0 commit comments

Comments
 (0)