From a04aad7a99b2e31f14a1f1e59b38178ad9df00ff Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 22 Mar 2006 10:56:49 +0000 Subject: [PATCH] puList.cxx: _list_box->getIntegerValue() returns -1 as long as no list entry was selected. Return 0 in this case, not an invalid string address (causing segfaults). dialogs.cxx: don't set property if no list entry was chosen. --- src/GUI/dialog.cxx | 4 +++- src/GUI/puList.cxx | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/GUI/dialog.cxx b/src/GUI/dialog.cxx index 6d9dafe19..d09d572e9 100644 --- a/src/GUI/dialog.cxx +++ b/src/GUI/dialog.cxx @@ -304,7 +304,9 @@ copy_from_pui (puObject * object, SGPropertyNode * node) // Special case to handle lists, as getStringValue cannot be overridden if(object->getType() & PUCLASS_LIST) { - node->setStringValue(((puList *) object)->getListStringValue()); + const char *s = ((puList *) object)->getListStringValue(); + if (s) + node->setStringValue(s); } else { diff --git a/src/GUI/puList.cxx b/src/GUI/puList.cxx index 5902a68ca..b99ccd405 100644 --- a/src/GUI/puList.cxx +++ b/src/GUI/puList.cxx @@ -79,7 +79,8 @@ puList::newList (char ** contents) char * puList::getListStringValue () { - return _contents[_list_box->getIntegerValue()]; + int i = _list_box->getIntegerValue(); + return i < 0 ? 0 : _contents[i]; } int -- 2.39.2