shithub: orca

Download patch

ref: febae883471be38061bc211929836ceae47744b4
parent: ec0f75ab74ab51ed6673cea514265338408f8bf3
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Jun 11 08:48:42 EDT 2020

plan9: make sure to include filename length into linebuf allocation logic

--- a/plan9.c
+++ b/plan9.c
@@ -1496,7 +1496,7 @@
 	field_init_fill(&fscr, h, w, '.');
 	field_init(&fsel);
 
-	linebuf = malloc(sizeof(Rune)*MAX(w+1, 64));
+	linebuf = malloc(sizeof(Rune)*MAX(w+1, 64+strlen(filename)));
 	memset(noteoff, 0, sizeof(noteoff));
 
 	mbuf_reusable_init(&mbuf);
@@ -1840,7 +1840,7 @@
 				memmove(&mscr.buffer[n*w], &mbuf.buffer[n*oldw], MIN(w, oldw));
 			mbuf_reusable_ensure_size(&mbuf, h, w);
 			memmove(mbuf.buffer, mscr.buffer, w*h);
-			linebuf = realloc(linebuf, sizeof(Rune)*MAX(w+1, 64));
+			linebuf = realloc(linebuf, sizeof(Rune)*MAX(w+1, 64+strlen(filename)));
 
 			field_copy(&field, &fscr);
 			field_resize_raw(&field, h, w);