encoding: In decodeTypeAndVal, quit the loop if read past the end of the input. Refs #1034.

Change-Id: I46a4d980cc10a71b2cc4beaeda9ef904541c042b