summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-12-01 16:53:21 +0100
committerMatthias Melcher <github@matthiasm.com>2023-12-01 16:53:27 +0100
commit96730f80cbc3b2d5aec2967a61f16bb2f02853e6 (patch)
tree2efb7ea0cf9f9f71aa7fa1838bd4b349ff9157d2 /src
parentccc21d381a41620a9fb91870ab2a47ef9309d148 (diff)
Adds some possible NULL references and small fixes
Diffstat (limited to 'src')
-rw-r--r--src/Fl_String.cxx3
-rw-r--r--src/Fl_Text_Buffer.cxx4
2 files changed, 4 insertions, 3 deletions
diff --git a/src/Fl_String.cxx b/src/Fl_String.cxx
index 1252f1202..8fd8e5f51 100644
--- a/src/Fl_String.cxx
+++ b/src/Fl_String.cxx
@@ -137,7 +137,8 @@ Fl_String &Fl_String::replace_(int at, int n_del, const char *ins, int n_ins) {
::memmove(buffer_+at, ins, n_ins);
}
size_ = new_size;
- buffer_[size_] = 0;
+ if (buffer_)
+ buffer_[size_] = 0;
return *this;
}
diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx
index caf4b3839..3bb8a10f0 100644
--- a/src/Fl_Text_Buffer.cxx
+++ b/src/Fl_Text_Buffer.cxx
@@ -1406,11 +1406,11 @@ int Fl_Text_Buffer::insert_(int pos, const char *text, int insertedLength)
/*
Remove a string from the buffer.
Unicode safe. Start and end must be at a character boundary.
+ Start must be less than end.
*/
void Fl_Text_Buffer::remove_(int start, int end)
{
- /* if the gap is not contiguous to the area to remove, move it there */
-
+ if (start >= end) return;
if (mCanUndo) {
if (mUndo->undoat == end && mUndo->undocut) {
// continue to remove text at the same cursor position