logrewrite: Fix the template reference counting

In case of the subst() and set() rewrite statements, when the
implementation was changed to pass a template to the constructor
instead of a string, the free() remained in the parser. While that was
supposed to free a string allocated by the parser, after the change,
that free'd the template that we had stored in the rewrite struct
itself.

To correct the issue, both the subst() and set() constructors will ref
the template, and the parser-side will unref it, instead of free()ing
it up.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>