Thu, 02 Feb 2006 20:03:17 +0000
[gaim-migrate @ 15467]
I think this fixes a bug with readlink, and somewhat handles an error condition that is not likely to happen.
| src/gtkmain.c | file | annotate | diff | comparison | revisions |
--- a/src/gtkmain.c Thu Feb 02 19:50:51 2006 +0000 +++ b/src/gtkmain.c Thu Feb 02 20:03:17 2006 +0000 @@ -387,8 +387,17 @@ /* But we still need to deal with symbolic links */ g_lstat(basebuf, &st); while ((st.st_mode & S_IFLNK) == S_IFLNK) { + int written; linkbuf = g_malloc(1024); - readlink(basebuf, linkbuf, 1024); + written = readlink(basebuf, linkbuf, 1024 - 1); + if (written == -1) + { + /* This really shouldn't happen, but do we + * need something better here? */ + g_free(linkbuf); + continue; + } + linkbuf[written] = '\0'; if (linkbuf[0] == G_DIR_SEPARATOR) { /* an absolute path */ fullbuf = g_strdup(linkbuf);