avdt_scb: fix dereferences of NULL
A recent change to this code added `int` in this for loop's first clause (good, since that's way more common than declaring `i` outside of the loop). Unfortunately, this caused the `*p_err_code = 0` to be interpreted as "create a new int* called p_err_code and set it to 0," rather than "set the value pointed to by p_err_code to 0." Caught by clang's static analyzer: > system/bt/stack/avdt/avdt_scb.cc:936:19: warning: Dereference of null pointer (loaded from variable 'p_err_code') [clang-analyzer-core.NullDereference]> system/bt/stack/avdt/avdt_scb.cc:941:19: warning: Dereference of null pointer (loaded from variable 'p_err_code') [clang-analyzer-core.NullDereference] > system/bt/stack/avdt/avdt_scb.cc:946:19: warning: Dereference of null pointer (loaded from variable 'p_err_code') [clang-analyzer-core.NullDereference] > system/bt/stack/avdt/avdt_scb.cc:955:23: warning: Dereference of null pointer (loaded from variable 'p_err_code') [clang-analyzer-core.NullDereference] > system/bt/stack/avdt/avdt_scb.cc:963:23: warning: Dereference of null pointer (loaded from variable 'p_err_code') [clang-analyzer-core.NullDereference] Bug: 180421437 Test: TreeHugger Change-Id: I834032e22da0ed558c25355c9d1cf20c11c8c530
Loading
Please register or sign in to comment