Skip to content

Instantly share code, notes, and snippets.

@desaster
Last active August 29, 2015 14:05
Show Gist options
  • Save desaster/f7ff53d899121a42d65d to your computer and use it in GitHub Desktop.
Save desaster/f7ff53d899121a42d65d to your computer and use it in GitHub Desktop.
epic5 /encoding crash
encoding #channel NONE
# (and another crash):
#encoding #channel ISO-8859-1
#encoding #channel NONE
--- source/recode.c 22 Apr 2014 14:05:30 -0000 1.25
+++ source/recode.c 16 Aug 2014 11:06:02 -0000
@@ -459,7 +459,7 @@
/*
* XXX TODO -- Pull out into a function to grow the rule set
*/
- recode_rules = (RecodeRule **)new_malloc(sizeof(RecodeRule *) * MAX_RECODING_RULES);
+ recode_rules = (RecodeRule **)new_malloc(sizeof(RecodeRule *) * MAX_RECODING_RULES + 1);
for (x = 0; x < MAX_RECODING_RULES; x++)
recode_rules[x] = NULL;
@@ -1061,10 +1061,14 @@
/* XXX TODO - Removing a rule should be in its own func */
else
{
- iconv_close(recode_rules[x]->inbound_handle);
- recode_rules[x]->inbound_handle = 0;
- iconv_close(recode_rules[x]->outbound_handle);
- recode_rules[x]->outbound_handle = 0;
+ if (recode_rules[x]->inbound_handle != 0) {
+ iconv_close(recode_rules[x]->inbound_handle);
+ recode_rules[x]->inbound_handle = 0;
+ }
+ if (recode_rules[x]->outbound_handle != 0) {
+ iconv_close(recode_rules[x]->outbound_handle);
+ recode_rules[x]->outbound_handle = 0;
+ }
new_free(&recode_rules[x]->encoding);
new_free(&recode_rules[x]->target);
new_free((char **)&recode_rules[x]);
$ gdb ./source/epic5 --args source/epic5 -B -s -l ../crash.irc
>
Program received signal SIGSEGV, Segmentation fault.
0x00000000004a6b8d in encoding (command=0x7ab638 "ENCODING", args=0x7ab64e "", subargs=0x0) at recode.c:1055
1055 else if (recode_rules[x]->magic == 1)
(gdb) bt
#0 0x00000000004a6b8d in encoding (command=0x7ab638 "ENCODING", args=0x7ab64e "", subargs=0x0) at recode.c:1055
#1 0x000000000043bf6b in parse_statement (stmt=0x79f778 "encoding #channel NONE", interactive=0, subargs=0x0)
at commands.c:3939
#2 0x000000000043859f in loader_std (file_contents=0x7ab88f "", file_contents_size=0,
filename=0x7ab5f8 "/home/desaster/epic/cvs/crash.irc", subargs=0x0, loadinfo=0x7302c0) at commands.c:2130
#3 0x0000000000437d4d in load (command=0x4e8ff0 "LOAD", args=0x79f6b4 "", subargs=0x4e86b9 "") at commands.c:1819
#4 0x0000000000478d74 in load_ircrc () at ./irc.c:1160
#5 0x0000000000479133 in main (argc=5, argv=0x7fffffffe658) at ./irc.c:1283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment