Previously this did a double free (and returned an error). Reported-by: Justin Ruggles Signed-off-by: Martin Storsjö <martin@martin.st>