Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » [FIXED] String::Replace(empty string,) => Out of memory!
Re: [BUG] String::Replace(empty string,) => Out of memory! [message #43075 is a reply to message #43074] Fri, 02 May 2014 18:27 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Well, this is an interesting issue. While obviously it should not crash, I somehow doubt that returning -1 is correct here.

More specifically, I believe that

String h("xxx");
h.Find("");

should return 0, because there IS empty substring at position 0 after all. In any case, such behaviour is consistent with e.g. STL (and I suspect all other libraries).

CONSOLE_APP_MAIN {
	std::string s = "xxxxxx";
	DDUMP(s.find(""));
}


Means, specifying empty string as string to be replaced is sort of illegal. Anyway, I have added a check to Replace. Thanks for pointing that out...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Surprising behavior of CParser
Next Topic: [FEATURE REQUEST] bool AMap::HasKey(K key) ;
Goto Forum:
  


Current Time: Sun Jun 09 10:15:36 CEST 2024

Total time taken to generate the page: 0.02126 seconds