Like the function pg_encoding_max_length_sql (src/backend/utils/mb/mbutils.c)
Only assertion is insufficient to avoid accessing array out-of-bounds.
This bug is live according Coverity at function: pg_verify_mbstr_len (src/backend/utils/mb/mbutils.c)
CID 1469870 (#1 of 1): Out-of-bounds access (OVERRUN)7.overrun-call:Overrunning callee's array of size 42 by passing argument src_encoding (which evaluates to 63) in call to pg_verify_mbstr_len. [show details]