[Circle] minor bug

From: Patrick Dughi (dughi@imaxx.net)
Date: 06/29/01

        Perhaps I'm wrong, but simple testing doesn't show that to be the

inside the index boot function, we have the following loop

  while (*buf1 != '$') {
    sprintf(buf2, "%s%s", prefix, buf1);
    if (!(db_file = fopen(buf2, "r"))) {
      log("SYSERR: %s: %s", buf2, strerror(errno));
    switch (mode) {
    case DB_BOOT_WLD:
    case DB_BOOT_OBJ:
    case DB_BOOT_MOB:
      discrete_load(db_file, mode, buf2);
    case DB_BOOT_ZON:
      load_zones(db_file, buf2);
    case DB_BOOT_HLP:
       * If you think about it, we have a race here.  Although, this is the
       * "point-the-gun-at-your-own-foot" type of race.
    case DB_BOOT_SHP:
      boot_the_shops(db_file, buf2, rec_count);

where - as should be obvious to anyone, buf2 is supposed to be the
filename (as per intial setup, discrete_load arguments, etc).  However,
since it's a global buffer instead of a local copy, and buf2 is used
in those functions (generally as the error message for fread_string in
parse_room, and others), it's only valid the first time through.

        Lucky for us, it appears to never be used.

        Unlucky for me, because I actually was using it, and it took a
while to nail down the error.  As a general rule, we probably shouldn't be
passing pointers to global character strings around as arguments, to,
well... anything?


   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |

This archive was generated by hypermail 2b30 : 12/05/01 PST