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

Commit 1197a76b authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: topshim: Fix pointers that point to dropped objects

In the following snippet, the lifetime of `u` doesn't extend to the
outside of the match scope, so `uuid_ptr` is actually pointing to a
dropped object which is the reason that the UUIDs registered with socket
profile are always wrong.

let uuid_ptr = match uuid {
    Some(u) => &u as *const Uuid,
    None => std::ptr::null(),
};

Bug: 247704030
Tag: #floss
Test: build.py --target test; also manual test with sdptool
Change-Id: I71e3b84feafe9497005d4d3bd4f735a7936daca1
parent d904e899
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ impl BtSocket {
        };

        let uuid_ptr = match uuid {
            Some(u) => &u as *const Uuid,
            Some(ref u) => u as *const Uuid,
            None => std::ptr::null(),
        };

@@ -199,7 +199,7 @@ impl BtSocket {
        };

        let uuid_ptr = match uuid {
            Some(u) => &u as *const Uuid,
            Some(ref u) => u as *const Uuid,
            None => std::ptr::null(),
        };