Skip to content

Commit 9eb217c

Browse files
Move destruction of callback out of the loop
This fixes issue phpredis#244 where we were seeing a SIGSEGV upon the second publish to a channel, given that the variable "z_fun" was freed inside the loop, and then called again.
1 parent 6f7087f commit 9eb217c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

redis.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5421,14 +5421,16 @@ PHP_METHOD(Redis, subscribe)
54215421
case R_SUB_CALLBACK_FT_TYPE:
54225422
MAKE_STD_ZVAL(z_ret);
54235423
call_user_function(EG(function_table), NULL, z_fun, z_ret, 3, z_args TSRMLS_CC);
5424-
efree(z_fun);
54255424
efree(z_ret);
54265425
break;
54275426
}
54285427
/* TODO: provide a way to break out of the loop. */
54295428
zval_dtor(z_tab);
54305429
efree(z_tab);
5431-
}
5430+
}
5431+
5432+
// Free our function
5433+
efree(z_fun);
54325434
}
54335435

54345436
/**

0 commit comments

Comments
 (0)