From 6a28c1cd6ee3652c90bd030e789e7783be18d179 Mon Sep 17 00:00:00 2001 From: mrsmola Date: Mon, 12 Mar 2007 20:22:58 +0000 Subject: [PATCH] changed some variable types from gchar buf[SMALL] to GString *buf. A bug causes bygfoot to crash in file_compress_files. Bug message: In file.c/file_compress_files, we used gchar buf[SMALL]; SMALL is defined to 10000. after a lot of seasons (19 within the test), the number of files grows too big. --- src/user.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/user.c b/src/user.c index 0c533702..07e902cc 100644 --- a/src/user.c +++ b/src/user.c @@ -993,16 +993,17 @@ user_show_sponsor_continue(void) void user_mm_load_file(const gchar *filename, GArray *mmatches) { - gchar prefix[SMALL], filename_local[SMALL], + GString *prefix = g_string_new(""); + gchar filename_local[SMALL], matches_file[SMALL]; GArray *mm_array = (mmatches == NULL) ? current_user.mmatches : mmatches; strcpy(filename_local, filename); - strncpy(prefix, filename_local, strlen(filename_local) - 8); - prefix[strlen(filename_local) - 8] = '\0'; + g_string_append_len(prefix, filename_local, strlen(filename_local) - 8); + //prefix[strlen(filename_local) - 8] = '\0'; - sprintf(matches_file, "%s___mmatches", prefix); + sprintf(matches_file, "%s___mmatches", prefix->str); file_decompress(filename_local); @@ -1011,11 +1012,13 @@ user_mm_load_file(const gchar *filename, GArray *mmatches) xml_mmatches_read(matches_file, mm_array); - strcat(prefix, "___*"); + g_string_append(prefix, "___*"); file_remove_files(prefix); if(mmatches == NULL) misc_string_assign(¤t_user.mmatches_file, filename_local); + + g_string_free(prefix, TRUE); } /** Add the last match to the MM file.