Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Lua] Fixed garbage collection segfault
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 23 Jul 2015 13:19:16 +0000 (15:19 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 15 Oct 2015 17:17:18 +0000 (19:17 +0200)
src/bindings/lua/lua_task.c

index 5aa00f8..890bbe6 100644 (file)
@@ -419,6 +419,11 @@ static const luaL_Reg task_functions[] = {
  */
 static int l_task_gc(lua_State* L)
 {
  */
 static int l_task_gc(lua_State* L)
 {
+  void *p = luaL_testudata(L, 1, TASK_MODULE_NAME);
+  if (p == NULL) {
+      return 0;
+  }
+
   msg_task_t task = *((msg_task_t*) luaL_checkudata(L, 1, TASK_MODULE_NAME));
   /* the task is NULL if I sent it to someone else */
   if (task != NULL) {
   msg_task_t task = *((msg_task_t*) luaL_checkudata(L, 1, TASK_MODULE_NAME));
   /* the task is NULL if I sent it to someone else */
   if (task != NULL) {