@@ -663,35 +663,35 @@ static INLINE unsigned font_get_arabic_replacement(
663663}
664664/* clang-format on */
665665
666- static char * font_driver_reshape_msg (const char * msg , unsigned char * buffer , size_t buffer_size )
666+ static char * font_driver_reshape_msg (const char * msg , unsigned char * s , size_t len )
667667{
668668 const unsigned char * src ;
669669 bool reverse = false;
670670 size_t msg_len = strlen (msg );
671671 /* worst case transformations are 2 bytes to 4 bytes -- aliaspider */
672672 size_t _len = (msg_len * 2 ) + 1 ;
673- unsigned char * dst = buffer ;
673+ unsigned char * dst = s ;
674674
675- if (buffer_size < _len )
675+ if (len < _len )
676676 {
677677 /* Input too long for the buffer: truncate to fit.
678678 * With a 512-byte caller buffer the limit is 255 source bytes,
679679 * which exceeds any realistic on-screen message. This path
680680 * is effectively dead code for normal HUD/OSD rendering.
681681 *
682682 * Place the truncated, null-terminated copy in the upper half
683- * of the buffer (offset buffer_size /2). The output grows forward
684- * from buffer [0] at most 2x the source consumption rate, so
683+ * of the buffer (offset len /2). The output grows forward
684+ * from s [0] at most 2x the source consumption rate, so
685685 * dst can never overtake src: after consuming k source bytes,
686- * dst <= 2k while src = buffer_size /2 + k, and 2k < buffer_size /2 + k
687- * holds for all k < buffer_size /2, which is guaranteed since
688- * msg_len < buffer_size /2. */
686+ * dst <= 2k while src = len /2 + k, and 2k < len /2 + k
687+ * holds for all k < len /2, which is guaranteed since
688+ * msg_len < len /2. */
689689 unsigned char * copy_dst ;
690- msg_len = (buffer_size / 2 ) - 1 ;
690+ msg_len = (len / 2 ) - 1 ;
691691 /* Back up to a UTF-8 character boundary */
692692 while (msg_len > 0 && IS_MBCONT ((const unsigned char * )& msg [msg_len ]))
693693 msg_len -- ;
694- copy_dst = buffer + (buffer_size / 2 );
694+ copy_dst = s + (len / 2 );
695695 memcpy (copy_dst , msg , msg_len );
696696 copy_dst [msg_len ] = '\0' ;
697697 msg = (const char * )copy_dst ;
@@ -781,8 +781,7 @@ static char* font_driver_reshape_msg(const char* msg, unsigned char *buffer, siz
781781 }
782782
783783 * dst = '\0' ;
784-
785- return (char * )buffer ;
784+ return (char * )s ;
786785}
787786#endif
788787
0 commit comments