Jump to content

String::format("%s", text) crash


photo

Recommended Posts

Hi, this is some seriously unexpected crash

	String a = String::format("%s %0.8f %0.12f %0.12f %0.8f %0.8f %0.8f %0.8f\n", "abc", 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f);
	Log::message(a.get());
	String b = String::format("%s %0.8f\n", "abc", 1.f);
	Log::message(b.get());
	String c = String::format("%s\n", "abc", 1); // OK, the '1' is ignored
	Log::message(c.get());
	String d = String::format("%s\n", "abc"); // CRASH
	Log::message(d.get());

Output:

abc 1.00000000 2.000000000000 3.000000000000 4.00000000 5.00000000 6.00000000 7.00000000
abc 1.00000000
abc
Exception thrown at 0x00007FF8B25350B3 (Unigine_double_x64d.dll) in ig_x64d.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

If the format string contains one %s and the va_list only contains the char pointer, then it will crash.

Link to comment
×
×
  • Create New...