[imp] Apache segfaults due to error in Horde.php logMessage()

Magnus Nordseth magnun at stud.ntnu.no
Fri Aug 1 17:14:38 PDT 2003


While investigating problems with apache childs segfaulting I came across
this posting:

  http://lists.horde.org/archives/imp/Week-of-Mon-20030526/032986.html 

Looking at Log.php (from the pear library) I found this comment:
/*
 * <b>You MUST call this method with the $var = &Log::singleton() syntax.
 * Without the ampersand (&) in front of the method name, you will not get
 * a reference, you will get a copy.</b>
*/

However, in Horde.php, the logger is instanciated like this:
$logger = Log::singleton($conf['log']['type'], $conf['log']['name'],
                         $conf['log']['ident'],$conf['log']['params']);

If I made the logMessage function return right before that instance got
used (the function returns right afterwards), ie before:
  
  $logger->log($message, $priority);

Then no segfaults occured. Problem area detected and confirmed :)

The minimal patch attatched seems to correct the problem.


-- 
Magnus Nordseth
Have spacesuit, will travel
-------------- next part --------------
--- Horde.php.orig	Sat Aug  2 02:11:01 2003
+++ Horde.php	Sat Aug  2 01:53:05 2003
@@ -183,7 +183,7 @@
         }
 
         include_once 'Log.php';
-        $logger = Log::singleton($conf['log']['type'], $conf['log']['name'],
+        $logger = &Log::singleton($conf['log']['type'], $conf['log']['name'],
                                  $conf['log']['ident'], $conf['log']['params']);
 
         if (!$logger) {


More information about the imp mailing list