Irene (Shi Ying) Huang wrote:
 > +               aspell = fopen (dic, "r");
 > +            perspell = fopen (filename, "a");
 > +            if (g_file_test (filename, G_FILE_TEST_EXISTS))
 > +                            perspell = fopen (filename, "a");
 > +            else {
 > +                    directory = g_build_filename (home_dir, 
 > ENCHANT_USER_PATH_EXTENSION, NULL);
 > +                    if (!g_file_test (directory, G_FILE_TEST_EXISTS) || 
 > !g_file_test 
(directory, G_FILE_TEST_IS_DIR))
 > +                            g_mkdir (directory , 0700);
 > +                    perspell = fopen (filename, "w");
 > +            }

Looks like a memory/file descriptor leak, since the fopen() from the
second line is just lost when you redo it in the if/else clauses.

Also, since you only close aspell & perspell if both are opened, do
you leak in cases where one fails but the other succeeded?

> +                     if (fgets (line, sizeof (line), aspell)) {
> +                             while (fgets (line, sizeof (line), aspell))
> +                                     fputs (line, perspell);

Are you intentionally throwing away the first line from the aspell
file?   If not, why not just dump the if line altogether?   If so,
it would be good to include a comment as to why, so future programmers
looking at it don't wonder why.

-- 
        -Alan Coopersmith-           alan.coopersmith at sun.com
         Sun Microsystems, Inc. - X Window System Engineering

Reply via email to