Author: silene
Date: Mon Apr 13 17:17:37 2009
New Revision: 34873
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34873&view=rev
Log:
Ported commits 34865, 34871, 34872 from trunk: fixes for use-after-free
segfaults.
Modified:
branches/1.6/src/dialogs.cpp
branches/1.6/src/menu_events.cpp
branches/1.6/src/serialization/parser.cpp
branches/1.6/src/serialization/preprocessor.cpp
branches/1.6/src/serialization/preprocessor.hpp
branches/1.6/src/show_dialog.cpp
Modified: branches/1.6/src/dialogs.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/dialogs.cpp?rev=34873&r1=34872&r2=34873&view=diff
==============================================================================
--- branches/1.6/src/dialogs.cpp (original)
+++ branches/1.6/src/dialogs.cpp Mon Apr 13 17:17:37 2009
@@ -244,7 +244,8 @@
const bool has_exit_button, const bool
ask_for_filename)
{
static int quit_prompt = 0;
- const std::string& tmp_title = (title.empty()) ? _("Save Game") : title;
+ std::string tmp_title = title;
+ if (tmp_title.empty()) tmp_title = _("Save Game");
bool ignore_opt = false;
int overwrite=0;
int res=0;
Modified: branches/1.6/src/menu_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/menu_events.cpp?rev=34873&r1=34872&r2=34873&view=diff
==============================================================================
--- branches/1.6/src/menu_events.cpp (original)
+++ branches/1.6/src/menu_events.cpp Mon Apr 13 17:17:37 2009
@@ -1021,7 +1021,7 @@
for(std::vector<unit>::const_iterator u =
recall_list.begin(); u != recall_list.end(); ++u) {
std::stringstream option, option_to_filter;
- const std::string& name = u->name().empty() ?
"-" : u->name();
+ std::string name = u->name().empty() ? "-" :
u->name();
option << IMAGE_PREFIX << u->absolute_image();
#ifndef LOW_MEM
Modified: branches/1.6/src/serialization/parser.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/serialization/parser.cpp?rev=34873&r1=34872&r2=34873&view=diff
==============================================================================
--- branches/1.6/src/serialization/parser.cpp (original)
+++ branches/1.6/src/serialization/parser.cpp Mon Apr 13 17:17:37 2009
@@ -27,6 +27,7 @@
#include "gettext.hpp"
#include "loadscreen.hpp"
#include "wesconfig.h"
+#include "serialization/preprocessor.hpp"
#include "serialization/tokenizer.hpp"
#include "foreach.hpp"
@@ -324,19 +325,7 @@
std::string parser::lineno_string(utils::string_map &i18n_symbols, std::string
const &lineno,
std::string const &error_string)
{
- std::vector< std::string > pos = utils::quoted_split(lineno, ' ');
- std::vector< std::string >::const_iterator i = pos.begin(), end =
pos.end();
- std::string included_from = _(" included from ");
- std::string res;
- while (i != end) {
- std::string const &line = *(i++);
- std::string const &file = i != end ? *(i++) : "<unknown>";
- if (!res.empty())
- res += included_from;
- res += file + ':' + line;
- }
- if (res.empty()) res = "???";
- i18n_symbols["pos"] = res;
+ i18n_symbols["pos"] = ::lineno_string(lineno);
std::string result = _(error_string.c_str());
foreach(utils::string_map::value_type& var, i18n_symbols)
boost::algorithm::replace_all(result, std::string("$") +
var.first, std::string(var.second));
Modified: branches/1.6/src/serialization/preprocessor.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/serialization/preprocessor.cpp?rev=34873&r1=34872&r2=34873&view=diff
==============================================================================
--- branches/1.6/src/serialization/preprocessor.cpp (original)
+++ branches/1.6/src/serialization/preprocessor.cpp Mon Apr 13 17:17:37 2009
@@ -166,7 +166,6 @@
preprocessor_streambuf(preprocessor_streambuf const &);
public:
preprocessor_streambuf(preproc_map *, std::string *);
- std::string lineno_string(std::string const &);
void error(const std::string &, const std::string &);
};
@@ -251,7 +250,7 @@
return static_cast<unsigned char>(*(begin + sz));
}
-std::string preprocessor_streambuf::lineno_string(std::string const &lineno)
+std::string lineno_string(const std::string &lineno)
{
std::vector< std::string > pos = utils::quoted_split(lineno, ' ');
std::vector< std::string >::const_iterator i = pos.begin(), end =
pos.end();
@@ -259,10 +258,13 @@
std::string res;
while (i != end) {
std::string const &line = *(i++);
- std::string const &file = i != end ? *(i++) : "<unknown>";
if (!res.empty())
res += included_from;
- res += file + ':' + line;
+ if (i != end)
+ res += *(i++);
+ else
+ res += "<unknown>";
+ res += ':' + line;
}
if (res.empty()) res = "???";
return res;
Modified: branches/1.6/src/serialization/preprocessor.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/serialization/preprocessor.hpp?rev=34873&r1=34872&r2=34873&view=diff
==============================================================================
--- branches/1.6/src/serialization/preprocessor.hpp (original)
+++ branches/1.6/src/serialization/preprocessor.hpp Mon Apr 13 17:17:37 2009
@@ -61,6 +61,7 @@
};
};
+std::string lineno_string(const std::string &lineno);
std::ostream& operator<<(std::ostream& stream, const preproc_map::value_type&
def);
Modified: branches/1.6/src/show_dialog.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/show_dialog.cpp?rev=34873&r1=34872&r2=34873&view=diff
==============================================================================
--- branches/1.6/src/show_dialog.cpp (original)
+++ branches/1.6/src/show_dialog.cpp Mon Apr 13 17:17:37 2009
@@ -373,7 +373,8 @@
const menu::sorter* sorter,
menu::style* menu_style)
{
- const std::string& title = (image.null())? caption : "";
+ std::string title;
+ if (image.null()) title = caption;
const dialog::style& style = (dialog_style)? *dialog_style :
dialog::default_style;
CVideo &disp = screen.video();
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits