[Tux4kids-commits] r217 - tuxmath/trunk/src

tholy-guest at alioth.debian.org tholy-guest at alioth.debian.org
Wed Aug 29 02:17:15 UTC 2007


Author: tholy-guest
Date: 2007-08-29 02:17:14 +0000 (Wed, 29 Aug 2007)
New Revision: 217

Modified:
   tuxmath/trunk/src/titlescreen.c
Log:
Fix potential bug if # of lessons is too large for statically-allocated lesson list.


Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2007-08-29 02:16:42 UTC (rev 216)
+++ tuxmath/trunk/src/titlescreen.c	2007-08-29 02:17:14 UTC (rev 217)
@@ -1690,6 +1690,7 @@
   int click_flag = 1;
 
   /* FIXME:Move file stuff into fileops.c.*/
+  /* Todo?: switch from readdir() to scandir() and use dynamic memory allocation? */
   unsigned char lesson_path[PATH_MAX];             //Path to lesson directory
   char* fgets_return_val;
   unsigned char name_buf[NAME_BUF_SIZE];
@@ -1783,7 +1784,7 @@
     memmove(&lesson_list[lessons].display_name, &name_buf[i], length + 1); 
     lessons++;
     fclose(tempFile);
-  } while (1);        // Loop will end when 'break' encountered
+  } while (lessons < MAX_LESSONS);  // Loop will end when 'break' encountered
 
   closedir(lesson_dir);	
 




More information about the Tux4kids-commits mailing list