SheetJS / js-cfb

:floppy_disk: OLE File Container Format
https://sheetjs.com/cfb-editor
Apache License 2.0
69 stars 15 forks source link

Infinite loop in build_full_paths with some files #7

Closed rossj closed 5 years ago

rossj commented 5 years ago

I've run into a file that enters an infinite loop with my changes in PR #6, even with your additional loop fix in commit 8d85fb6e74e3b84e440a3a107b01350bc2b30464. The infinite loop doesn't happen in previous version 1.1.0.

I believe the dad tree for this file is constructed a bit incorrectly, thus it has a loop in it. I haven't looked into fixing the dad tree, but I did manage to avoid the infinite loop by slightly changing the final naming loop to:

    for(i=1; i < pl; ++i) {
        if(FI[i].type === 0 /* unknown */) continue;
        if (i !== dad[i]) {
            j = i;
            do {
                j = dad[j];
                FP[i] = FP[j] + "/" + FP[i];
            } while (j !== 0 && -1 !== dad[j] && j != dad[j]);
        }
        dad[i] = -1;
    }

I'm unable to share the file publicly, but I can email it if you would like.

SheetJSDev commented 5 years ago

Please share the file (dev@sheetjs.com)

reviewher commented 5 years ago

The latest update should have fixed the issue, please reopen if that is not the case