polaris- 10 лет назад
Родитель
Сommit
9f66580d7e
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      src/core/gdbstub/gdbstub.cpp

+ 3 - 2
src/core/gdbstub/gdbstub.cpp

@@ -306,6 +306,7 @@ static void SendReply(const char* reply) {
     command_length = strlen(reply);
     command_length = strlen(reply);
     if (command_length + 4 > sizeof(command_buffer)) {
     if (command_length + 4 > sizeof(command_buffer)) {
         LOG_ERROR(Debug_GDBStub, "command_buffer overflow in SendReply");
         LOG_ERROR(Debug_GDBStub, "command_buffer overflow in SendReply");
+        return;
     }
     }
 
 
     memcpy(command_buffer + 1, reply, command_length);
     memcpy(command_buffer + 1, reply, command_length);
@@ -403,12 +404,12 @@ static void ReadCommand() {
     }
     }
 
 
     while ((c = ReadByte()) != GDB_STUB_END) {
     while ((c = ReadByte()) != GDB_STUB_END) {
-        command_buffer[command_length++] = c;
-        if (command_length == sizeof(command_buffer)) {
+        if (command_length >= sizeof(command_buffer)) {
             LOG_ERROR(Debug_GDBStub, "gdb: command_buffer overflow\n");
             LOG_ERROR(Debug_GDBStub, "gdb: command_buffer overflow\n");
             SendPacket(GDB_STUB_NACK);
             SendPacket(GDB_STUB_NACK);
             return;
             return;
         }
         }
+        command_buffer[command_length++] = c;
     }
     }
 
 
     u8 checksum_received = HexCharToValue(ReadByte()) << 4;
     u8 checksum_received = HexCharToValue(ReadByte()) << 4;