src/video/x11/SDL_x11modes.c
branchSDL-1.2
changeset 5559 9f181779cfdd
parent 4318 34a0a589b9c4
child 6131 804c6c62c55f
--- a/src/video/x11/SDL_x11modes.c	Sat Jun 04 15:34:32 2011 -0400
+++ b/src/video/x11/SDL_x11modes.c	Thu Jul 07 11:49:46 2011 -0700
@@ -465,10 +465,13 @@
 
         metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r");
         if ( metro_fp != NULL ) {
-            int major, minor, patch, version;
+            int major, minor, patch, version, scannum;
             major = 0; minor = 0; patch = 0;
-            fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
+            scannum = fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
             fclose(metro_fp);
+            if ( (scannum < 0) || (scannum > 3) ) {
+                return 0;  /* we need _something_ useful from fscanf(). */
+            }
             version = major*100+minor*10+patch;
             if ( version < 431 ) {
                 return 0;