summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNei <ailin.nemui@gmail.com>2017-07-05 14:47:30 +0000
committerNei <ailin.nemui@gmail.com>2017-07-05 14:47:30 +0000
commit5e26325317c72a04c1610ad952974e206384d291 (patch)
tree0d00b367c799581fea82cbe89f27d377736559df
parent1656dc1e549cfbbe330aafcd8b92177aa9a5555f (diff)
parentf67e7669341bfe2962623a3e9bbb46f9cd9d60e7 (diff)
downloadirssi-5e26325317c72a04c1610ad952974e206384d291.zip
Merge branch 'security' into 'master'
Security Closes #10 See merge request !17
-rw-r--r--src/core/misc.c3
-rw-r--r--src/core/nicklist.c17
2 files changed, 13 insertions, 7 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 7249b1a7..e589b8c5 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -556,6 +556,9 @@ char *my_asctime(time_t t)
int len;
tm = localtime(&t);
+ if (tm == NULL)
+ return g_strdup("???");
+
str = g_strdup(asctime(tm));
len = strlen(str);
diff --git a/src/core/nicklist.c b/src/core/nicklist.c
index 54dfb5fb..0bc88ab8 100644
--- a/src/core/nicklist.c
+++ b/src/core/nicklist.c
@@ -54,23 +54,26 @@ static void nick_hash_add(CHANNEL_REC *channel, NICK_REC *nick)
static void nick_hash_remove(CHANNEL_REC *channel, NICK_REC *nick)
{
- NICK_REC *list;
+ NICK_REC *list, *newlist;
list = g_hash_table_lookup(channel->nicks, nick->nick);
if (list == NULL)
return;
- if (list == nick || list->next == NULL) {
- g_hash_table_remove(channel->nicks, nick->nick);
- if (list->next != NULL) {
- g_hash_table_insert(channel->nicks, nick->next->nick,
- nick->next);
- }
+ if (list == nick) {
+ newlist = nick->next;
} else {
+ newlist = list;
while (list->next != nick)
list = list->next;
list->next = nick->next;
}
+
+ g_hash_table_remove(channel->nicks, nick->nick);
+ if (newlist != NULL) {
+ g_hash_table_insert(channel->nicks, newlist->nick,
+ newlist);
+ }
}
/* Add new nick to list */