Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid cell coordinate range causes infinite loop #519

Closed
rdarcy1 opened this issue May 30, 2018 · 0 comments
Closed

Invalid cell coordinate range causes infinite loop #519

rdarcy1 opened this issue May 30, 2018 · 0 comments

Comments

@rdarcy1
Copy link
Contributor

rdarcy1 commented May 30, 2018

This is:

- [x] a bug report
- [ ] a feature request

What is the expected behavior?

An exception should be thrown for an invalid range, or maybe just the start cell should be returned.

What is the current behavior?

The program gets stuck in a loop and PHP runs out of memory.

I think the offending loop is \PhpOffice\PhpSpreadsheet\Cell\Coordinate line 372

while ($currentCol != $endCol) {
    ...
}

Probably needs a magnitude comparison rather than a straight equality comparison, since if an invalid range is given the current column will never equal the end column.

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

// Gets stuck in a loop
\PhpOffice\PhpSpreadsheet\Cell\Coordinate::extractAllCellReferencesInRange('Z1:A1');


// Which means the following gets stuck, causing a hard to debug memory error for
// code that isn't necessarily obviously wrong.
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$spreadsheet->getActiveSheet()
    ->mergeCellsByColumnAndRow(0, 1, 1, 1);

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet 1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant