From 0994ffc19518899ab2b7759b1c9726be0dbd1418 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Tue, 5 Oct 2010 22:39:41 +0200 Subject: [PATCH] Don't crash in strutils::trim() with empty strings --- simgear/misc/strutils.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/simgear/misc/strutils.cxx b/simgear/misc/strutils.cxx index be05d692..cc56aa41 100644 --- a/simgear/misc/strutils.cxx +++ b/simgear/misc/strutils.cxx @@ -131,10 +131,9 @@ namespace simgear { static string do_strip( const string& s, int striptype ) { - // if (s.empty()) - // return s; - string::size_type len = s.length(); + if( len == 0 ) // empty string is trivial + return s; string::size_type i = 0; if (striptype != RIGHTSTRIP) { -- 2.39.5