From 497697dd3bcf6a8bb431cab62d6f8ecbcedc6455 Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 2 Oct 2008 16:26:09 +0000 Subject: [PATCH] Fix a crash bug when modperl was loaded on some arches PERL_SYS_INIT3 was added to modperl in r1155-1158 to fix modperl on arches like hppa. This added an invalid cast which caused a segfault. If you have: const char *pArgv[]; Then pArgv will point to the same memory location as &pArgv. This pointer was then casted to (char ***) which is one level of pointers too much for this pointer. Thanks to an anonymous reporter who pointed out the crash. Thanks to pippijin for helping me understand the C++ magic. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1237 726aef4b-f618-498e-8847-2d620e286838 --- modules/modperl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/modperl.cpp b/modules/modperl.cpp index 515dc5d4..00d7c671 100644 --- a/modules/modperl.cpp +++ b/modules/modperl.cpp @@ -984,8 +984,8 @@ EXTERN_C void boot_DynaLoader (pTHX_ CV* cv); bool CModPerl::OnLoad(const CString & sArgs, CString & sMessage) { int iArgc = 5; - const char * pArgv[] = { "", "-e", "0", "-T", "-w", NULL }; - PERL_SYS_INIT3( &iArgc, (char ***)&pArgv, &environ ); + char * pArgv[] = { "", "-e", "0", "-T", "-w", NULL }; + PERL_SYS_INIT3( &iArgc, &pArgv, &environ ); m_pPerl = perl_alloc(); perl_construct(m_pPerl);