mirror of
				https://bitbucket.org/mfeemster/fractorium.git
				synced 2025-10-30 08:50:25 -04:00 
			
		
		
		
	--Bug fixes
-Another attempt to fix null termination bug with reading files for Xml processing.
This commit is contained in:
		| @ -332,12 +332,12 @@ static bool ReadFile(const char* filename, string& buf, bool nullTerminate = tru | ||||
|  | ||||
| 		if (const auto pos = ifs.tellg())//Ensure it exists and wasn't empty. | ||||
| 		{ | ||||
| 			buf.resize(pos + streampos(nullTerminate ? 1 : 0)); | ||||
| 			buf.resize(pos);// +streampos(nullTerminate ? 1 : 0)); | ||||
| 			ifs.seekg(0, ios::beg); | ||||
| 			ifs.read(&buf[0], pos); | ||||
|  | ||||
| 			if (nullTerminate && (buf[buf.size() - 1] != 0))//Optionally NULL terminate if they want to treat it as a string, and it's not terminated arleady. | ||||
| 				buf[buf.size() - 1] = 0; | ||||
| 				buf.push_back(0); | ||||
|  | ||||
| 			return true; | ||||
| 		} | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Person
					Person