[Circle] [Bug] file_to_string

From: Patrick Dughi (dughi@imaxx.net)
Date: 09/11/00


        Just looking through it the other day, and noticed something -
inner loop looks like;


  do {
    fgets(tmp, READ_SIZE, fl);
    tmp[strlen(tmp) - 1] = '\0'; /* take off the trailing \n */
    strcat(tmp, "\r\n");

    if (!feof(fl)) {
      if (strlen(buf) + strlen(tmp) + 1 > MAX_STRING_LENGTH) {
        log("SYSERR: %s: string too big (%d max)", name,
                MAX_STRING_LENGTH);
        *buf = '\0';
        return (-1);
      }
      strcat(buf, tmp);
    }
  } while (!feof(fl));


        Shouldn't that do a fclose(fl) before return'ing (-1), just in
case?

        Though, I seriously doubt anyone's crashed over this.

                                                PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/11/01 PDT