diff --git a/codec.go b/codec.go
index <HASH>..<HASH> 100644
--- a/codec.go
+++ b/codec.go
@@ -70,9 +70,10 @@ func validateBytes(b []byte) (err error) {
 			return err
 		}
 
-		if len(b) < size {
+		if len(b) < size || size < 0 {
 			return fmt.Errorf("invalid value for size")
 		}
+
 		b = b[size:]
 	}
fix underflow error found by fuzzing