Fix a heap-use-after-free in a unit test (#7230)
* Fix a heap-use-after-free in a unit test The data passed to IAsyncFile::write must remain valid until the future is ready. * Use holdWhile instead of a new state variable
This commit is contained in:
parent
a0bb585260
commit
1997e6057c
|
@ -2706,8 +2706,8 @@ ACTOR Future<Void> updateNewestSoftwareVersion(std::string folder,
|
|||
0600));
|
||||
|
||||
SWVersion swVersion(latestVersion, currentVersion, minCompatibleVersion);
|
||||
auto s = swVersionValue(swVersion);
|
||||
ErrorOr<Void> e = wait(errorOr(newVersionFile->write(s.toString().c_str(), s.size(), 0)));
|
||||
Value s = swVersionValue(swVersion);
|
||||
ErrorOr<Void> e = wait(holdWhile(s, errorOr(newVersionFile->write(s.begin(), s.size(), 0))));
|
||||
if (e.isError()) {
|
||||
throw e.getError();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue