php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33491 extended mysqli class crashes when result is not object
Submitted: 2005-06-27 15:01 UTC Modified: 2005-06-27 19:44 UTC
From: sniper@php.net Assigned: georg (profile)
Status: Closed Package: MySQLi related
PHP Version: 5CVS-2005-06-27 (dev) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sniper@php.net
New email:
PHP Version: OS:

 

 [2005-06-27 15:01 UTC] sniper@php.net
Description:
------------
(gdb) run tt.php
Starting program: /www/php/bin/php tt.php
[Thread debugging using libthread_db enabled]
[New Thread -1208100640 (LWP 4755)]
PHP Fatal error:  Call to a member function fetch_row() on a non-object in tt.php on line 8

Fatal error: Call to a member function fetch_row() on a non-object in tt.php on line 8

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208100640 (LWP 4755)]
0x0818cac4 in instanceof_function_ex (instance_ce=0x8431fac, ce=0x8409f60, interfaces_only=0 '\0') at /usr/src/php5/Zend/zend_operators.c:1564
1564                    if (instanceof_function(instance_ce->interfaces[i], ce TSRMLS_CC)) {
(gdb) bt
#0  0x0818cac4 in instanceof_function_ex (instance_ce=0x8431fac, ce=0x8409f60, interfaces_only=0 '\0') at /usr/src/php5/Zend/zend_operators.c:1564
#1  0x0818cb2d in instanceof_function (instance_ce=0x8431fac, ce=0x8409f60) at /usr/src/php5/Zend/zend_operators.c:1582
#2  0x08094fc7 in mysqli_objects_free_storage (object=0x8433cfc) at /usr/src/php5/ext/mysqli/mysqli.c:132
#3  0x081a8547 in zend_objects_store_free_object_storage (objects=0x839eeec) at /usr/src/php5/Zend/zend_objects_API.c:82
#4  0x08182b87 in shutdown_executor () at /usr/src/php5/Zend/zend_execute_API.c:272
#5  0x0818f416 in zend_deactivate () at /usr/src/php5/Zend/zend.c:823
#6  0x0814e5fa in php_request_shutdown (dummy=0x0) at /usr/src/php5/main/main.c:1237
#7  0x081fa4b9 in main (argc=2, argv=0xbffff414) at /usr/src/php5/sapi/cli/php_cli.c:1142


Reproduce code:
---------------
<?php

class DB extends mysqli
{
  public function query_single($query) {
    $result = parent::query($query);
    $row = $result->fetch_row(); // <- Here be crash
    return (isset($row[0]) ? $row[0] : '');
  }
}

// Works when using mysqli class directly
/*
$DB = new mysqli('localhost', 'root', '', '');
var_dump($DB->query_single('SELECT DATE()'));
*/

// Segfault when using the DB class which extends mysqli
$DB = new DB('localhost', 'root', '', '');
var_dump($DB->query_single('SELECT DATE()'));



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-27 15:03 UTC] sniper@php.net
Georg, I'm not absolutely sure if this is just Mysqli issue, but if you could check this out..:)

 [2005-06-27 19:44 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC