Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/EionRobb/skype4pidgin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEion Robb <eion@robbmob.com>2008-04-21 04:44:56 +0400
committerEion Robb <eion@robbmob.com>2008-04-21 04:44:56 +0400
commita761c67a3098a2641a258a4378f845cd0a8f6432 (patch)
tree04c6b2859d0ce7ce15c1d892a01984211d5c90cf /skype_messaging_x11.c
parentb9c2ad0f041f0633b0a8873a84d97da063f97233 (diff)
Fix to is_skype_running() to stop corner case crash at startup
Diffstat (limited to 'skype_messaging_x11.c')
-rw-r--r--skype_messaging_x11.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/skype_messaging_x11.c b/skype_messaging_x11.c
index 2401c17..ed347c3 100644
--- a/skype_messaging_x11.c
+++ b/skype_messaging_x11.c
@@ -238,22 +238,22 @@ is_skype_running()
gchar* stat_path;
FILE *fh;
gchar exec_name[15];
- struct stat *statobj = NULL;
+ struct stat *statobj = g_new(struct stat, 1);
//open /proc
GDir *procdir = g_dir_open("/proc", 0, NULL);
//go through directories that are numbers
while((temp = g_dir_read_name(procdir)))
{
- pid = atoi(temp);
+ pid = atoi(temp);
+ g_free(temp);
if (!pid)
continue;
// /proc/{pid}/stat contains lots of juicy info
stat_path = g_strdup_printf("/proc/%d/stat", pid);
fh = fopen(stat_path, "r");
- // fscanf (file, "%*d (%15[^)]"
pid = fscanf(fh, "%*d (%15[^)]", exec_name);
fclose(fh);
- if (strcmp(exec_name, "skype") != 0)
+ if (!g_str_equal(exec_name, "skype"))
{
g_free(stat_path);
continue;
@@ -265,10 +265,13 @@ is_skype_running()
if (statobj->st_uid == getuid())
{
//this copy of skype was started by us
+ g_dir_close(procdir);
+ g_free(statobj);
return TRUE;
}
}
- g_dir_close(procdir);
+ g_dir_close(procdir);
+ g_free(statobj);
return FALSE;
}