Fix T96510: ASAN failure when selecting text in Text Editor

Regression in 541ba68991
This commit is contained in:
Germano Cavalcante
2022-03-21 13:32:34 +11:00
committed by Campbell Barton
parent b9123b806f
commit 8ecaa2d624

View File

@@ -1501,7 +1501,8 @@ char *txt_sel_to_buf(Text *text, size_t *r_buf_strlen)
if (linef == linel) {
length = charl - charf;
buf = MEM_mallocN(length + 1, "sel buffer");
memcpy(buf, linef->line + charf, length + 1);
memcpy(buf, linef->line + charf, length);
buf[length] = '\0';
}
else {
/* Add 1 for the '\n' */