# HG changeset patch # User Richard Laager # Date 1138910597 0 # Node ID cb7461d56b5eeac7384b788a6181004a5b86d977 # Parent 8f9c66e4af8724a6f20c92ac2804fa8fc69a8a0c [gaim-migrate @ 15467] I think this fixes a bug with readlink, and somewhat handles an error condition that is not likely to happen. diff -r 8f9c66e4af87 -r cb7461d56b5e src/gtkmain.c --- 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);