From:             [EMAIL PROTECTED]
Operating system: Windows 2000 SP2
PHP version:      4.1.2
PHP Bug Type:     COM related
Bug description:  "case" causes AV

This script let php crash.
The Problem is the case-statement in the convert_field_crash-function, but
with an If-statement this crash doesen't occur.

<?php

define('adDBTimeStamp', 135);

$conn = new COM( "ADODB.Connection" );

$rs = new COM( "ADODB.Recordset" );
$conn->Provider = 'SQLOLEDB';
$conn->Open( "Server=wincubix;Uid=oebb;Pwd=oebb;Database=cubix" );
@$rs->Open( "SELECT * FROM news ", $conn);

echo '<table>';
while (!$rs->EOF) {
        echo '<tr>';
    for ($i=0; $i < $rs->Fields->Count(); $i++) {
                echo '<td>';
                echo convert_field_crash($rs->Fields[$i]);
                echo '</td>';
    }
        echo '</tr>';
    $rs->MoveNext();
}
echo '</table>';

$rs->Close;
$conn->Close;

$rs->Release();
$rs = null;

$conn->Release();
$conn = null;

function convert_field($field) {
        if ($field->type == adDBTimeStamp) {
                if (empty($field->Value)) return '';
                return strftime('%Y-%m-%d %T', $field->value);
        } else {
                return $field->Value;
        }
}

function convert_field_crash($field) {
        // case verursacht AV
        switch($field->type) {
                case adDBTimeStamp:
                        return strftime('%Y-%m-%d %T', $field->value);
                        break;
                default:
                        return $field->Value;
        }
}

?>
-- 
Edit bug report at http://bugs.php.net/?id=17173&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=17173&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=17173&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=17173&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=17173&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17173&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=17173&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=17173&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=17173&r=submittedtwice
register_globals:    http://bugs.php.net/fix.php?id=17173&r=globals

Reply via email to