Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d5c87b7 authored by Kenny Root's avatar Kenny Root Committed by Android Git Automerger
Browse files

am fb79b7da: am 12da9d74: Fix buffer compacting in NativeDaemonConnector

Merge commit 'fb79b7da'

* commit 'fb79b7da':
  Fix buffer compacting in NativeDaemonConnector
parents 3559d1d1 fb79b7da
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -109,6 +109,10 @@ final class NativeDaemonConnector implements Runnable {
                int count = inputStream.read(buffer, start, BUFFER_SIZE - start);
                if (count < 0) break;

                // Add our starting point to the count and reset the start.
                count += start;
                start = 0;

                for (int i = 0; i < count; i++) {
                    if (buffer[i] == 0) {
                        String event = new String(buffer, start, i - start);
@@ -141,6 +145,9 @@ final class NativeDaemonConnector implements Runnable {
                        start = i + 1;
                    }
                }

                // We should end at the amount we read. If not, compact then
                // buffer and read again.
                if (start != count) {
                    final int remaining = BUFFER_SIZE - start;
                    System.arraycopy(buffer, start, buffer, 0, remaining);