summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2015-12-15 10:16:56 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2015-12-15 10:16:56 +0000
commit14669685d8f5ede33543db5213b0249095ab802f (patch)
tree005819f908bec54efe23eb84399efdff0426537c
parentdd8c33b19a5b7845b14a4ffc7e2cddefe203f137 (diff)
Fix Fl_Browser if text argument to some methods is NULL (STR #3269).
Fl_Browser::add(), Fl_Browser::insert(), and Fl_Browser::text() didn't test if the provided text argument was NULL, although this was explicitly allowed in the documentation. Also applied some minor documentation fixes. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10966 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--CHANGES1
-rw-r--r--src/Fl_Browser.cxx6
2 files changed, 5 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 5efc7dbbf..b7e8fe83b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -59,6 +59,7 @@ CHANGES IN FLTK 1.3.4 RELEASED: ??? ?? ????
Bug fixes
+ - Fix Fl_Browser if text argument to some methods is NULL (STR #3269).
- Fixed missing image release in fluid (STR #2840).
- Fixed out-of-bounds memory access in fluid (STR #3263).
- fluid doesn't output trailing white space in .fl files after
diff --git a/src/Fl_Browser.cxx b/src/Fl_Browser.cxx
index b9c140780..c81c88edc 100644
--- a/src/Fl_Browser.cxx
+++ b/src/Fl_Browser.cxx
@@ -80,7 +80,7 @@ void* Fl_Browser::item_next(void* item) const {return ((FL_BLINE*)item)->next;}
/**
Returns the previous item before \p item.
\param[in] item The 'current' item
- \returns The previous item before \p item, or NULL if there none before this one.
+ \returns The previous item before \p item, or NULL if there are none before this one.
\see item_first(), item_last(), item_next(), item_prev()
*/
void* Fl_Browser::item_prev(void* item) const {return ((FL_BLINE*)item)->prev;}
@@ -284,6 +284,7 @@ void Fl_Browser::insert(int line, FL_BLINE* item) {
\param[in] d Optional pointer to user data to be associated with the new line.
*/
void Fl_Browser::insert(int line, const char* newtext, void* d) {
+ if (!newtext) newtext = ""; // STR #3269
int l = (int) strlen(newtext);
FL_BLINE* t = (FL_BLINE*)malloc(sizeof(FL_BLINE)+l);
t->length = (short)l;
@@ -319,6 +320,7 @@ void Fl_Browser::move(int to, int from) {
void Fl_Browser::text(int line, const char* newtext) {
if (line < 1 || line > lines) return;
FL_BLINE* t = find_line(line);
+ if (!newtext) newtext = ""; // STR #3269
int l = (int) strlen(newtext);
if (l > t->length) {
FL_BLINE* n = (FL_BLINE*)malloc(sizeof(FL_BLINE)+l);
@@ -789,7 +791,7 @@ int Fl_Browser::visible(int line) const {
}
/**
- Returns the line number of the currently selected line, or 0 if none.
+ Returns the line number of the currently selected line, or 0 if none selected.
\returns The line number of current selection, or 0 if none selected.
\see select(), selected(), value(), item_select(), item_selected()
*/