diff --git a/src/c_api.cpp b/src/c_api.cpp index d8a8deaf57b0..0ff6d4228380 100644 --- a/src/c_api.cpp +++ b/src/c_api.cpp @@ -1966,17 +1966,17 @@ int LGBM_BoosterPredictSparseOutput(BoosterHandle handle, int LGBM_BoosterFreePredictSparse(void* indptr, int32_t* indices, void* data, int indptr_type, int data_type) { API_BEGIN(); if (indptr_type == C_API_DTYPE_INT32) { - delete reinterpret_cast(indptr); + delete[] reinterpret_cast(indptr); } else if (indptr_type == C_API_DTYPE_INT64) { - delete reinterpret_cast(indptr); + delete[] reinterpret_cast(indptr); } else { Log::Fatal("Unknown indptr type in LGBM_BoosterFreePredictSparse"); } - delete indices; + delete[] indices; if (data_type == C_API_DTYPE_FLOAT32) { - delete reinterpret_cast(data); + delete[] reinterpret_cast(data); } else if (data_type == C_API_DTYPE_FLOAT64) { - delete reinterpret_cast(data); + delete[] reinterpret_cast(data); } else { Log::Fatal("Unknown data type in LGBM_BoosterFreePredictSparse"); }