fix memory leak when passing invalid parents type

Passing invalid parents type to Commit.create just raises
an exception without freeing the allocated signatures,
arrays and tree obj.
fix leak when alt array has entry type != string

The double array walking is not that great, but it has the nice side effect
of adding the alternative paths only if the input is somewhat valid.