Free old value of property after updating it

When updating the value of a property the old value is freed before the
new value is set. Instead keep a pointer to the old value, set the new
value and then free the old value. That way the value of the property is
never in an invalid state.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>