Safety improvements for tinystr (#8004)