Переглянути джерело

tools: do not send empty commands to the server

Daniele Bartolini 6 роки тому
батько
коміт
c3f51a772b
3 змінених файлів з 6 додано та 1 видалено
  1. 1 0
      CHANGELOG.md
  2. 3 0
      tools-imgui/widgets/console.inl
  3. 2 1
      tools/widgets/console_view.vala

+ 1 - 0
CHANGELOG.md

@@ -5,4 +5,5 @@ Changelog
 ------
 *DD MMM YYYY*
 
+* tools: fixed a crash when entering empty commands in the console
 * tools: fixed an issue that prevented the data compiler from restoring and saving its state when launched by the level editor

+ 3 - 0
tools-imgui/widgets/console.inl

@@ -65,6 +65,9 @@ void console_send_command(TCPSocket& client, char* cmd)
 	const char* delim = " ";
 	const char* token = strtok_r(cmd, delim, &saveptr);
 
+	if (token == NULL)
+		return;
+
 	json << "{\"type\":\"command\",\"args\":[";
 	while (token != NULL)
 	{

+ 2 - 1
tools/widgets/console_view.vala

@@ -112,7 +112,8 @@ namespace Crown
 				if (text[0] == ':')
 				{
 					string[] args = text[1:text.length].split(" ");
-					_console_client.send(DeviceApi.command(args));
+					if (args.length > 0)
+						_console_client.send(DeviceApi.command(args));
 				}
 				else
 				{