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!
[FIXED] String::Replace(empty string,) => Out of memory! [message #43074] Fri, 02 May 2014 16:16 Go to previous message
omari is currently offline  omari
Messages: 266
Registered: March 2010
Experienced Member
Hi,

a call to
String::Replace(f, r)
crash if f.GetCount is equal to 0, with message:

Out of memory!
Request size : 905969755 B
U++ allocated memory: 442520 KB


I found that is because Replace use t_find (StringFind.hpp line 30):

template <int step> // Template parameter to be a constant
int t_find(const char *ptr, int slen, const char *p, int len, int from)


and t_find returns 0 if slen is equal to 0.

		else
		if(len == 1) {
			char p0 = p[0];
			while(s <= e) {
				if(*s == p0)
					return (int)(s - ptr);
				s += step;
			}
		}
		else
			return 0;   <---- (line 87)

if t_find return -1 instead of 0, it resolve the issu.

Regards
omari.



regards
omari.

[Updated on: Sat, 18 March 2017 16:05]

Report message to a moderator

 
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: Wed May 15 00:25:46 CEST 2024

Total time taken to generate the page: 0.01842 seconds