2
0
Michael Ragazzon 2 жил өмнө
parent
commit
4705f9e4b4

+ 7 - 4
Source/Core/URL.cpp

@@ -30,6 +30,7 @@
 #include "../../Include/RmlUi/Core/StringUtilities.h"
 #include "../../Include/RmlUi/Core/StringUtilities.h"
 #include "../../Include/RmlUi/Core/URL.h"
 #include "../../Include/RmlUi/Core/URL.h"
 #include <string.h>
 #include <string.h>
+#include <stdio.h>
 
 
 namespace Rml {
 namespace Rml {
 
 
@@ -506,8 +507,9 @@ void URL::ConstructURL() const
 		if (port > 0)
 		if (port > 0)
 		{
 		{
 			RMLUI_ASSERTMSG( !host.empty(), "Can't have a port without a host!" );
 			RMLUI_ASSERTMSG( !host.empty(), "Can't have a port without a host!" );
-			char port_string[16];
-			sprintf(port_string, ":%d/", port);
+			constexpr size_t port_buffer_size = 16;
+			char port_string[port_buffer_size];
+			snprintf(port_string, port_buffer_size, ":%d/", port);
 			url += port_string;
 			url += port_string;
 		}
 		}
 		else
 		else
@@ -545,7 +547,8 @@ void URL::ConstructURL() const
 String URL::UrlEncode(const String &value)
 String URL::UrlEncode(const String &value)
 {
 {
 	String encoded;
 	String encoded;
-	char hex[4] = {0,0,0,0};
+	constexpr size_t hex_buffer_size = 4;
+	char hex[hex_buffer_size] = {0, 0, 0, 0};
 
 
 	encoded.clear();
 	encoded.clear();
 
 
@@ -557,7 +560,7 @@ String URL::UrlEncode(const String &value)
 			encoded += c;
 			encoded += c;
 		else
 		else
 		{
 		{
-			sprintf(hex, "%%%02X", c);
+			snprintf(hex, hex_buffer_size, "%%%02X", c);
 			encoded += hex;
 			encoded += hex;
 		}
 		}
 	}
 	}