diff options
author | Yang Ni <yangni@google.com> | 2017-04-19 10:05:53 -0700 |
---|---|---|
committer | Yang Ni <yangni@google.com> | 2017-04-21 20:51:06 +0000 |
commit | cf51dd13955c1eab521a2a610d1c7ca26fc01e05 (patch) | |
tree | 84989007f8b37d8b9496115428d9feb1c8b542b7 | |
parent | adc46414b68614c95c3cfbfd0a9de38bfa27c2be (diff) | |
download | rs-cf51dd13955c1eab521a2a610d1c7ca26fc01e05.tar.gz |
Increment sys ref count of input/output Allocations
Bug: 30596040
In case such Allocations lose their other references and get deleted,
while being used by a rsForEach() call.
Test: CTS on x86_64 emulator
Change-Id: I01bd9ef9235ad963b461d235f4d63c481e7c034d
(cherry picked from commit 972be5160b8b52d07582fd0f0585524e2f7e143d)
-rw-r--r-- | driver/rsdRuntimeStubs.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp index 504f0980..74c79182 100644 --- a/driver/rsdRuntimeStubs.cpp +++ b/driver/rsdRuntimeStubs.cpp @@ -683,10 +683,23 @@ void rsForEachInternal(int slot, Allocation* inputs[RS_KERNEL_MAX_ARGUMENTS]; for (int i = 0; i < numInputs; i++) { inputs[i] = (Allocation*)allocs[i].p; + CHECK_OBJ(inputs[i]); + inputs[i]->incSysRef(); + } + Allocation* out = nullptr; + if (hasOutput) { + out = (Allocation*)allocs[numInputs].p; + CHECK_OBJ(out); + out->incSysRef(); } - Allocation* out = hasOutput ? (Allocation*)allocs[numInputs].p : nullptr; rsrForEach(rsc, s, slot, numInputs, numInputs > 0 ? inputs : nullptr, out, nullptr, 0, (RsScriptCall*)options); + for (int i = 0; i < numInputs; i++) { + inputs[i]->decSysRef(); + } + if (hasOutput) { + out->decSysRef(); + } } void __attribute__((overloadable)) rsForEach(::rs_script script, |