diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-10-09 14:18:11 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2013-10-09 19:46:00 +0200 |
commit | 2386a92c1e6e8ec263edb4dc4fdcfeaa4673ce1f (patch) | |
tree | 27a8b34bbf6925fc7d7b201bdbb932cfd0ae0bb4 | |
parent | d703c8f64c6cd650bb753cf1f6f39b3e81f06a41 (diff) |
pyuno: set up fake command line in getComponentContext()
Easy to trigger the assert in osl_getCommandArgCount(), just
run instdir/*/program/python and "import unohelper".
Avoid that by setting up a fake command line, hopefully
nobody expects to be able to give relevant args to python...
Change-Id: I0df6c23d6ecbb3c2bce81a9d5bcecdcb1729ddbb
-rw-r--r-- | pyuno/source/module/pyuno_module.cxx | 8 | ||||
-rw-r--r-- | sal/osl/unx/process_impl.cxx | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/pyuno/source/module/pyuno_module.cxx b/pyuno/source/module/pyuno_module.cxx index d9d510a8086b..e34b675837c7 100644 --- a/pyuno/source/module/pyuno_module.cxx +++ b/pyuno/source/module/pyuno_module.cxx @@ -27,6 +27,7 @@ #include <osl/module.hxx> #include <osl/thread.h> +#include <osl/process.h> #include <osl/file.hxx> #include <typelib/typedescription.hxx> @@ -260,6 +261,13 @@ static PyObject* getComponentContext( } else { + // cppu::defaultBootstrap_InitialComponentContext expects + // command line arguments to be present + static char * argv [1]; + argv[0] = strdup( + "this is just a fake and cheap imitation of a command line"); + osl_setCommandArgs(1, argv); + OUString iniFile; if( path.isEmpty() ) { diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index b75e7725b2e0..00766ccf4304 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -176,7 +176,7 @@ sal_uInt32 SAL_CALL osl_getCommandArgCount (void) sal_uInt32 result = 0; pthread_mutex_lock (&(g_command_args.m_mutex)); - SAL_WARN_IF (g_command_args.m_nCount == 0, "sal.osl", "osl_setCommandArgs() not called before calling osl_getCommandArgCount()"); + assert (g_command_args.m_nCount != 0); if (g_command_args.m_nCount > 0) result = g_command_args.m_nCount - 1; pthread_mutex_unlock (&(g_command_args.m_mutex)); |