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

Commit 00685bad authored by Rama Vaddula's avatar Rama Vaddula Committed by Linux Build Service Account
Browse files

Surface: Initialize variable and add a defensive check

Initialize buf variable and make sure to check for return
value of dequeueBuffer() before sending to the client.

Change-Id: I0569f2d45825fab0e5d0f38fc91a07990f57c7ab
parent d3c6dfd4
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -126,9 +126,12 @@ int Surface::hook_queueBuffer(ANativeWindow* window,
int Surface::hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
int Surface::hook_dequeueBuffer_DEPRECATED(ANativeWindow* window,
        ANativeWindowBuffer** buffer) {
        ANativeWindowBuffer** buffer) {
    Surface* c = getSelf(window);
    Surface* c = getSelf(window);
    ANativeWindowBuffer* buf;
    ANativeWindowBuffer* buf = NULL;
    int fenceFd = -1;
    int fenceFd = -1;
    int result = c->dequeueBuffer(&buf, &fenceFd);
    int result = c->dequeueBuffer(&buf, &fenceFd);

    if (result != NO_ERROR) return result;

    sp<Fence> fence(new Fence(fenceFd));
    sp<Fence> fence(new Fence(fenceFd));
    int waitResult = fence->waitForever("dequeueBuffer_DEPRECATED");
    int waitResult = fence->waitForever("dequeueBuffer_DEPRECATED");
    if (waitResult != OK) {
    if (waitResult != OK) {