codec: fixed potential crash in NSCodec implementation