memset(&smp, 0, sizeof(smp));
hlua_lua2smp(L, 3, &smp);
- /* Store the sample in a variable. */
+ /* Store the sample in a variable. We don't need to dup the smp, vars API
+ * already takes care of duplicating dynamic var data.
+ */
smp_set_owner(&smp, s->be, s->sess, s, 0);
if (lua_gettop(L) == 4 && lua_toboolean(L, 4))
memset(&smp, 0, sizeof(smp));
hlua_lua2smp(L, 3, &smp);
- /* Store the sample in a variable. */
+ /* Store the sample in a variable. We don't need to dup the smp, vars API
+ * already takes care of duplicating dynamic var data.
+ */
smp_set_owner(&smp, s->be, s->sess, s, 0);
if (lua_gettop(L) == 4 && lua_toboolean(L, 4))
memset(&smp, 0, sizeof(smp));
hlua_lua2smp(L, 3, &smp);
- /* Store the sample in a variable. */
+ /* Store the sample in a variable. We don't need to dup the smp, vars API
+ * already takes care of duplicating dynamic var data.
+ */
smp_set_owner(&smp, htxn->p, htxn->s->sess, htxn->s, htxn->dir & SMP_OPT_DIR);
if (lua_gettop(L) == 4 && lua_toboolean(L, 4))
/* Convert the returned value in sample. */
hlua_lua2smp(stream->hlua->T, -1, smp);
+ /* dup the smp before popping the related lua value and
+ * returning it to haproxy
+ */
+ smp_dup(smp);
lua_pop(stream->hlua->T, 1);
return 1;
/* Convert the returned value in sample. */
hlua_lua2smp(stream->hlua->T, -1, smp);
+ /* dup the smp before popping the related lua value and
+ * returning it to haproxy
+ */
+ smp_dup(smp);
lua_pop(stream->hlua->T, 1);
/* Set the end of execution flag. */