summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-11-12 13:16:44 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-11-12 13:40:18 +0100
commit963612613ac95d391ea051f596d24fff6cf3b8d2 (patch)
tree800c4478ec77a804d74545c2786e3ed8aafb6610 /sal
parent0943adb2f7ec319891c11889b40c9a69f0d1027e (diff)
Work around Coverity warnings about std::length_error
...escaping from main or being unexpected, in various places, which started when 62dbe2e6eb30660f252b4e2c048f4aecf28e41c6 "Clean up osl_getSystemPathFromFileURL implementation" made osl_getSystemPathFromFileURL (indirectly) call rtl_uString_newConcatAsciiL, which can throw std::length_error. There is no ideal fix for this. "The distinguishing characteristic of logic errors [i.e., incl. std::length_error] is that they are due to errors in the internal logic of the program. In theory, they are preventable." ([std.exceptions]) That means that throwing a logic error is more akin to raising an assert than to throwing some other kind or exception that is intended to be handled by the program. Which in turn means that it would generally be more useful to cause such errors to cause calls to std::abort (and produce a core/backtrace), than to catch and try to somehow handle them. But there appears to be no way to tell Coverity not to emit warnings about uncaught logic errors, and it tends to emit quite a number of them for each signle "root cause," so be pragmatic for now and catch it close to the root. Change-Id: Iee71f50e3304954e9e88f326e0fa2167b6051ca2
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file_url.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index 839eae27e6e9..cc9907a96060 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -22,6 +22,7 @@
#include "system.hxx"
#include <cassert>
+#include <stdexcept>
#include <limits.h>
#include <errno.h>
#include <strings.h>
@@ -204,8 +205,13 @@ oslFileError getSystemPathFromFileUrl(
oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath )
{
OUString path;
- auto e = getSystemPathFromFileUrl(
- OUString::unacquired(&ustrFileURL), &path, true);
+ oslFileError e;
+ try {
+ e = getSystemPathFromFileUrl(
+ OUString::unacquired(&ustrFileURL), &path, true);
+ } catch (std::length_error) {
+ e = osl_File_E_RANGE;
+ }
if (e == osl_File_E_None) {
rtl_uString_assign(pustrSystemPath, path.pData);
}