Fix -Wlogical-op-parentheses warning
Fix -Wsequence-point warning
Fix crash in decode() on malformed input