Don't access free'd memory.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3087 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-12-30 23:10:57 +00:00 committed by cras
parent 0d7f682cbe
commit f3d43d9137

View File

@ -113,15 +113,16 @@ static void text_chunk_line_free(TEXT_BUFFER_REC *buffer, LINE_REC *line)
{ {
TEXT_CHUNK_REC *chunk; TEXT_CHUNK_REC *chunk;
const unsigned char *text; const unsigned char *text;
unsigned char *tmp = NULL; unsigned char cmd, *tmp = NULL;
for (text = line->text;; text++) { for (text = line->text;; text++) {
if (*text != '\0') if (*text != '\0')
continue; continue;
text++; text++;
if (*text == LINE_CMD_CONTINUE || *text == LINE_CMD_EOL) { cmd = *text;
if (*text == LINE_CMD_CONTINUE) if (cmd == LINE_CMD_CONTINUE || cmd == LINE_CMD_EOL) {
if (cmd == LINE_CMD_CONTINUE)
memcpy(&tmp, text+1, sizeof(char *)); memcpy(&tmp, text+1, sizeof(char *));
/* free the previous block */ /* free the previous block */
@ -133,11 +134,11 @@ static void text_chunk_line_free(TEXT_BUFFER_REC *buffer, LINE_REC *line)
text_chunk_destroy(buffer, chunk); text_chunk_destroy(buffer, chunk);
} }
if (*text == LINE_CMD_EOL) if (cmd == LINE_CMD_EOL)
break; break;
text = tmp-1; text = tmp-1;
} else if (*text == LINE_CMD_INDENT_FUNC) { } else if (cmd == LINE_CMD_INDENT_FUNC) {
text += sizeof(int (*) ()); text += sizeof(int (*) ());
} }
} }