mirror of
https://github.com/fltk/fltk.git
synced 2026-06-05 16:12:13 +08:00
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
This commit is contained in:
@@ -59,6 +59,7 @@ CHANGES IN FLTK 1.3.4 RELEASED: ??? ?? ????
|
|||||||
|
|
||||||
Bug fixes
|
Bug fixes
|
||||||
|
|
||||||
|
- Fix Fl_Browser if text argument to some methods is NULL (STR #3269).
|
||||||
- Fixed missing image release in fluid (STR #2840).
|
- Fixed missing image release in fluid (STR #2840).
|
||||||
- Fixed out-of-bounds memory access in fluid (STR #3263).
|
- Fixed out-of-bounds memory access in fluid (STR #3263).
|
||||||
- fluid doesn't output trailing white space in .fl files after
|
- fluid doesn't output trailing white space in .fl files after
|
||||||
|
|||||||
+4
-2
@@ -80,7 +80,7 @@ void* Fl_Browser::item_next(void* item) const {return ((FL_BLINE*)item)->next;}
|
|||||||
/**
|
/**
|
||||||
Returns the previous item before \p item.
|
Returns the previous item before \p item.
|
||||||
\param[in] item The 'current' 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()
|
\see item_first(), item_last(), item_next(), item_prev()
|
||||||
*/
|
*/
|
||||||
void* Fl_Browser::item_prev(void* item) const {return ((FL_BLINE*)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.
|
\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) {
|
void Fl_Browser::insert(int line, const char* newtext, void* d) {
|
||||||
|
if (!newtext) newtext = ""; // STR #3269
|
||||||
int l = (int) strlen(newtext);
|
int l = (int) strlen(newtext);
|
||||||
FL_BLINE* t = (FL_BLINE*)malloc(sizeof(FL_BLINE)+l);
|
FL_BLINE* t = (FL_BLINE*)malloc(sizeof(FL_BLINE)+l);
|
||||||
t->length = (short)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) {
|
void Fl_Browser::text(int line, const char* newtext) {
|
||||||
if (line < 1 || line > lines) return;
|
if (line < 1 || line > lines) return;
|
||||||
FL_BLINE* t = find_line(line);
|
FL_BLINE* t = find_line(line);
|
||||||
|
if (!newtext) newtext = ""; // STR #3269
|
||||||
int l = (int) strlen(newtext);
|
int l = (int) strlen(newtext);
|
||||||
if (l > t->length) {
|
if (l > t->length) {
|
||||||
FL_BLINE* n = (FL_BLINE*)malloc(sizeof(FL_BLINE)+l);
|
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.
|
\returns The line number of current selection, or 0 if none selected.
|
||||||
\see select(), selected(), value(), item_select(), item_selected()
|
\see select(), selected(), value(), item_select(), item_selected()
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user