Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

On windows buf in 'make_object_info2' can not be stack allocated

For some strange reason the stack get trashed otherwise, stack is to small?
  • Loading branch information...
commit 00143130d2dc7dfdfc5afe1734ff6784ab9ed385 1 parent 2914e14
@dgud dgud authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 c_src/cl_nif.c
View
17 c_src/cl_nif.c
@@ -2312,9 +2312,10 @@ ERL_NIF_TERM make_object_info2(ErlNifEnv* env, ERL_NIF_TERM key, ecl_object_t*
info2_fn_t func, ecl_info_t* info, size_t num_info)
{
size_t returned_size = 0;
- cl_ulong buf[MAX_INFO_SIZE];
+ cl_long *buf;
cl_int err;
unsigned int i;
+ ERL_NIF_TERM result;
if (!enif_is_atom(env, key))
return enif_make_badarg(env);
@@ -2323,10 +2324,16 @@ ERL_NIF_TERM make_object_info2(ErlNifEnv* env, ERL_NIF_TERM key, ecl_object_t*
i++;
if (i == num_info)
return enif_make_badarg(env); // or error ?
- if (!(err = (*func)(obj1->opaque, obj2->opaque, info[i].info_id, sizeof(buf), buf, &returned_size)))
- return enif_make_tuple2(env, ATOM(ok), make_info_value(env, &info[i], buf, returned_size));
- else
- return ecl_make_error(env, err);
+ if (!(buf = enif_alloc(sizeof(cl_long) * MAX_INFO_SIZE)))
+ ecl_make_error(env, CL_OUT_OF_RESOURCES);
+ if (!(err = (*func)(obj1->opaque, obj2->opaque, info[i].info_id,
+ sizeof(cl_long) * MAX_INFO_SIZE, buf, &returned_size))) {
+ result = enif_make_tuple2(env, ATOM(ok), make_info_value(env, &info[i], buf, returned_size));
+ enif_free(buf);
+ return result;
+ }
+ enif_free(buf);
+ return ecl_make_error(env, err);
}
/******************************************************************************
Please sign in to comment.
Something went wrong with that request. Please try again.