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

Commit 06b2e9eb authored by Ajay Panicker's avatar Ajay Panicker Committed by Akshay Thakker
Browse files

[DO NOT MERGE ANYWHERE] Null terminate MAP instance information

Bug: 26437927
Change-Id: I673de7f7c68b9a02b234bb99c6f89c7fc36f90c9
parent d772f940
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -394,15 +394,16 @@ public class BluetoothMapUtils {
    static public byte[] truncateUtf8StringToBytearray(String utf8String, int maxLength)
            throws UnsupportedEncodingException {

        byte[] utf8Bytes = null;
        byte[] utf8Bytes = new byte[utf8String.length() + 1];
        try {
            utf8Bytes = utf8String.getBytes("UTF-8");
            System.arraycopy(utf8String.getBytes("UTF-8"), 0,
                             utf8Bytes, 0, utf8String.length());
        } catch (UnsupportedEncodingException e) {
            Log.e(TAG,"truncateUtf8StringToBytearray: getBytes exception ", e);
            throw e;
        }

        if (utf8Bytes.length > (maxLength - 1)) {
        if (utf8Bytes.length > maxLength) {
            /* if 'continuation' byte is in place 200,
             * then strip previous bytes until utf-8 start byte is found */
            if ( (utf8Bytes[maxLength - 1] & 0xC0) == 0x80 ) {