ridljar/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java | 23 +++------- sal/osl/unx/process.cxx | 5 ++ 2 files changed, 14 insertions(+), 14 deletions(-)
New commits: commit f4d147ef956de834a7402bea88a1aec296c38ef7 Author: Damjan Jovanovic <[email protected]> AuthorDate: Mon Feb 27 20:19:39 2023 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Feb 28 11:12:06 2023 +0000 InputStreamToXInputStreamAdapter.readBytes() should read... until the buffer is full, or the file ends. It shouldn't care about available(). (cherry-picked from f04910427d25ede98b84b90df7cc5a12d1adc695) Change-Id: I4ad17c614ba336ff21883248715861f6af1fbc2b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147934 Reviewed-by: Stephan Bergmann <[email protected]> Tested-by: Jenkins diff --git a/ridljar/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java b/ridljar/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java index d547b1e7ce17..dd634e771370 100644 --- a/ridljar/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java +++ b/ridljar/com/sun/star/lib/uno/adapter/InputStreamToXInputStreamAdapter.java @@ -79,29 +79,24 @@ public final class InputStreamToXInputStreamAdapter implements XInputStream { { try { long bytesRead; + int totalBytesRead = 0; if (b[0] == null || b[0].length < len) { b[0] = new byte[len]; } - if (len >iIn.available()) { - bytesRead = iIn.read(b[0], 0, iIn.available()); - } - else{ - bytesRead = iIn.read(b[0], 0, len); - } // Casting bytesRead to an int is okay, since the user can // only pass in an integer length to read, so the bytesRead // must <= len. - if (bytesRead < b[0].length) { - int outSize = bytesRead > 0 ? (int)bytesRead : 0; - byte[] out = new byte[outSize]; - System.arraycopy(b[0], 0, out, 0, outSize); - b[0] = out; + while ((len > 0) && ((bytesRead = iIn.read(b[0], totalBytesRead, len)) > 0)) { + totalBytesRead += (int)bytesRead; + len -= (int)bytesRead; } - if (bytesRead <= 0) { - return 0; + if (totalBytesRead < b[0].length) { + byte[] out = new byte[totalBytesRead]; + System.arraycopy(b[0], 0, out, 0, totalBytesRead); + b[0] = out; } - return ((int)bytesRead); + return totalBytesRead; } catch (IOException e) { throw new com.sun.star.io.IOException("reader error", e); } commit 4f743219e85e61f622a8dadc028c144010eecd4d Author: Caolán McNamara <[email protected]> AuthorDate: Mon Feb 27 20:49:08 2023 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Feb 28 11:11:56 2023 +0000 cid#1521506 silence Thread deadlock and cid#1521510 Thread deadlock annotation is getting a bit spamy Change-Id: I3120562c0f7ca996f53d14965efe7af506be6d19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147935 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx index f75534fdc311..7d6936265c0b 100644 --- a/sal/osl/unx/process.cxx +++ b/sal/osl/unx/process.cxx @@ -329,6 +329,7 @@ static void ChildStatusProc(void *pData) else pChild->m_status = -1; + // coverity[lock_order : FALSE] - incorrect report of lock order error osl_setCondition(pChild->m_terminated); } @@ -731,8 +732,12 @@ oslProcess SAL_CALL osl_getProcess(oslProcessIdentifier Ident) pProcImpl->m_status = pChild->m_status; + // coverity[lock_order : FALSE] - incorrect report of lock order error if (osl_checkCondition(pChild->m_terminated)) + { + // coverity[lock_order : FALSE] - incorrect report of lock order error osl_setCondition(pProcImpl->m_terminated); + } } else pProcImpl->m_pnext = nullptr;
