changeset 17929:6fe95ee39422

Fix osd_show_msg alignment and make sure msg strings get properly 0 terminated. Thanks to Jonas Jermann (jjermann _At_ gmx _Dot_ net) for the report.
author albeu
date Thu, 23 Mar 2006 15:17:23 +0000
parents e0f20946e398
children 81cbc8debd3c
files mplayer.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mplayer.c	Thu Mar 23 01:22:43 2006 +0000
+++ b/mplayer.c	Thu Mar 23 15:17:23 2006 +0000
@@ -1091,6 +1091,7 @@
 static void set_osd_msg(int id, int level, int time, char* fmt, ...) {
     mp_osd_msg_t *msg,*last=NULL;
     va_list va;
+    int r;
    
     // look if the id is already in the stack
     for(msg = osd_msg_stack ; msg && msg->id != id ;
@@ -1107,8 +1108,9 @@
     }
     // write the msg
     va_start(va,fmt);
-    vsnprintf(msg->msg, 63, fmt, va);
+    r = vsnprintf(msg->msg, 64, fmt, va);
     va_end(va);
+    if(r >= 64) msg->msg[63] = 0;
     // set id and time
     msg->id = id;
     msg->level = level;
@@ -3881,7 +3883,7 @@
 	  rm_osd_msg(OSD_MSG_OSD_STATUS);
     } break;
     case MP_CMD_OSD_SHOW_TEXT :  {
-      set_osd_msg(OSD_MSG_TEXT,1,osd_duration,"%64s",cmd->args[0].v.s);
+      set_osd_msg(OSD_MSG_TEXT,1,osd_duration,"%-.63s",cmd->args[0].v.s);
     } break;
     case MP_CMD_LOADFILE : {
       play_tree_t* e = play_tree_new();