- if (!len) return "";
- char* buf = text.GetWriteBuf(len);
-
- int pos = SendMsg(2027, len, (long)buf);
+ if (!len) {
+ if (linePos) *linePos = 0;
+ return "";
+ }
+ // Need an extra byte because SCI_GETCURLINE writes a null to the string
+ char* buf = text.GetWriteBuf(len+1);
+
+ int pos = SendMsg(2027, len+1, (long)buf);