Guard against 0 len while decoding
Set alt_layout earlier to shut up coverity
Fix an unlikely memory leak found by coverity
Fix some small bugs found by coverity
Merge pull request #47 from pedrocr/coverity-fixes

Fix a few small issues found by coverity