mirror of
				https://bitbucket.org/mfeemster/fractorium.git
				synced 2025-10-31 01:10:24 -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. | 		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.seekg(0, ios::beg); | ||||||
| 			ifs.read(&buf[0], pos); | 			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. | 			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; | 			return true; | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Person
					Person