Improve handling of invalid input in dlls/comctl32/datetime.c

Gerald Pfeifer gerald at pfeifer.com
Fri Dec 25 05:18:53 CST 2009


Otherwise max_count will be undefined in the following loop may do 
interesting things it seems.  (Does Coverity diagnose similar items?)

Gerald

ChangeLog:
Improve handling of invalid input in DATETIME_ReturnFieldWidth.

diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c
index c240d4f..08c7082 100644
--- a/dlls/comctl32/datetime.c
+++ b/dlls/comctl32/datetime.c
@@ -38,6 +38,7 @@
  *    -- FORMATCALLBACK
  */
 
+#include <assert.h>
 #include <math.h>
 #include <string.h>
 #include <stdarg.h>
@@ -619,6 +620,9 @@ DATETIME_ReturnFieldWidth (const DATETIME_INFO *infoPtr, HDC hdc, int count, SHO
 		    lctype = LOCALE_SMONTHNAME1;
 		    max_count = 12;
 		    break;
+		default:
+		    assert(0);
+		    max_count=0;
 		}
 
 		cx = 0;



More information about the wine-patches mailing list