aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2016-02-17 09:30:18 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2016-02-17 09:30:18 -0500
commit73b694bc7e76d6c536881f8e4649a7c7dbba965e (patch)
treeaa8a409866a8a29b147876954caa558289f639c9
parentcedef41777ac60f0a3de75bc8a95f6bfbb87fbfa (diff)
downloadtextadept-73b694bc7e76d6c536881f8e4649a7c7dbba965e.tar.gz
textadept-73b694bc7e76d6c536881f8e4649a7c7dbba965e.zip
Fixed potential buffer overflow; src/textadept.c
Thanks to Markus F.X.J. Oberhumer.
-rw-r--r--src/textadept.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/textadept.c b/src/textadept.c
index bcff6fcf..81e1d910 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -1882,7 +1882,10 @@ static void lL_notify(lua_State *L, struct SCNotification *n) {
lua_pushinteger(L, n->modifiers), lua_setfield(L, -2, "modifiers");
lua_pushinteger(L, n->modificationType);
lua_setfield(L, -2, "modification_type");
- lua_pushstring(L, n->text), lua_setfield(L, -2, "text");
+ if (n->text && n->length)
+ lua_pushlstring(L, n->text, n->length), lua_setfield(L, -2, "text");
+ else
+ lua_pushstring(L, n->text), lua_setfield(L, -2, "text");
lua_pushinteger(L, n->length), lua_setfield(L, -2, "length"); // SCN_MODIFIED
//lua_pushinteger(L, n->linesAdded), lua_setfield(L, -2, "lines_added");
//lua_pushinteger(L, n->message), lua_setfield(L, -2, "message");