[haiku-commits] r35629 - haiku/trunk/src/kits/app

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 27 Feb 2010 10:44:30 +0100 (CET)

Author: stippi
Date: 2010-02-27 10:44:30 +0100 (Sat, 27 Feb 2010)
New Revision: 35629
Changeset: http://dev.haiku-os.org/changeset/35629/haiku

Modified:
   haiku/trunk/src/kits/app/Message.cpp
Log:
Strings in BMessages don't necessarily have to be \0 terminated. Use the already
known length to print the stream so printf() doesn't potentially crash when
trying a strlen() on the string. Fixes for example printing B_KEY_DOWN messages,
where such strings are used, in certain conditions.

Review welcome, printf() formatting is not one of my strengths. :-)


Modified: haiku/trunk/src/kits/app/Message.cpp
===================================================================
--- haiku/trunk/src/kits/app/Message.cpp        2010-02-27 01:08:26 UTC (rev 
35628)
+++ haiku/trunk/src/kits/app/Message.cpp        2010-02-27 09:44:30 UTC (rev 
35629)
@@ -590,8 +590,8 @@
                                        break;
 
                                case B_STRING_TYPE:
-                                       printf("string(\"%s\", %ld bytes)\n", 
(char *)pointer,
-                                               (long)size);
+                                       printf("string(\"%.*s\", %ld bytes)\n", 
(int)size,
+                                               (char *)pointer, (long)size);
                                        break;
 
                                case B_INT8_TYPE:


Other related posts:

  • » [haiku-commits] r35629 - haiku/trunk/src/kits/app - superstippi