Added workspace allocation error
@@ -156,6 +156,14 @@ c_int osqp_solve(Work * work){
c_int exitflag = 0;
c_int iter;
+ // Check if workspace has been initialized
+ if (!work){
+ #ifdef PRINTING
+ c_print("ERROR: Workspace not initialized!\n");
+ #endif
+ return -1;
+ }
+
#ifdef PROFILING
tic(work->timer); // Start timer
#endif
@@ -277,6 +285,7 @@ c_int osqp_solve(Work * work){
c_int osqp_cleanup(Work * work){
c_int exitflag=0;
+ if (work) { // If workspace has been allocated
// Free Data
if (work->data) {
if (work->data->P)
@@ -323,8 +332,7 @@ c_int osqp_cleanup(Work * work){
c_free(work->pol);
}
- // Free work Variables
- if (work) {
+ // Free other Variables
if (work->x)
c_free(work->x);
if (work->z)
