encode_col(-9) explodes #1244

Closed
opened 2018-08-28 05:27:42 +00:00 by MichaelRCruz · 3 comments
MichaelRCruz commented 2018-08-28 05:27:42 +00:00 (Migrated from github.com)

encode_col(-9)

<--- Last few GCs --->

[23635:0x104801e00] 28594 ms: Scavenge 1397.9 (1424.8) -> 1397.9 (1426.3) MB, 13.0 / 0.0 ms (average mu = 0.200, current mu = 0.058) allocation failure
[23635:0x104801e00] 29869 ms: Mark-sweep 1398.9 (1426.3) -> 1398.9 (1425.8) MB, 1274.1 / 0.0 ms (+ 0.0 ms in 30 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1291 ms) (average mu = 0.127, current mu = 0.034) alloca

<--- JS stacktrace --->

==== JS stack trace =========================================

> encode_col(-9) <--- Last few GCs ---> [23635:0x104801e00] 28594 ms: Scavenge 1397.9 (1424.8) -> 1397.9 (1426.3) MB, 13.0 / 0.0 ms (average mu = 0.200, current mu = 0.058) allocation failure [23635:0x104801e00] 29869 ms: Mark-sweep 1398.9 (1426.3) -> 1398.9 (1425.8) MB, 1274.1 / 0.0 ms (+ 0.0 ms in 30 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1291 ms) (average mu = 0.127, current mu = 0.034) alloca <--- JS stacktrace ---> ==== JS stack trace =========================================
SheetJSDev commented 2018-08-28 05:32:13 +00:00 (Migrated from github.com)

encode_col expects a nonnegative argument; passing a negative argument will result in an infinite loop. Fortunately that's easy to fix: https://github.com/SheetJS/js-xlsx/blob/master/bits/27_csfutils.js#L7 should throw an error on a negative argument.

If this is coming from an attempt to read an actual file, that's a sign of a deeper issue and it would be appreciated if you could share the offending file.

`encode_col` expects a nonnegative argument; passing a negative argument will result in an infinite loop. Fortunately that's easy to fix: https://github.com/SheetJS/js-xlsx/blob/master/bits/27_csfutils.js#L7 should throw an error on a negative argument. If this is coming from an attempt to read an actual file, that's a sign of a deeper issue and it would be appreciated if you could share the offending file.
MichaelRCruz commented 2018-08-28 05:55:52 +00:00 (Migrated from github.com)

I passed it a -9, but it did not throw.

I passed it a -9, but it did not throw.
SheetJSDev commented 2018-08-28 06:00:27 +00:00 (Migrated from github.com)

It currently doesn't but should. Here's a quick fix, feel free to submit as a PR:

function encode_col(col/*:number*/)/*:string*/ { if(col < 0) throw new Error("invalid column " + col); var s=""; for(++col; col; col=Math.floor((col-1)/26)) s = String.fromCharCode(((col-1)%26) + 65) + s; return s; }
It currently doesn't but should. Here's a quick fix, feel free to submit as a PR: ```js function encode_col(col/*:number*/)/*:string*/ { if(col < 0) throw new Error("invalid column " + col); var s=""; for(++col; col; col=Math.floor((col-1)/26)) s = String.fromCharCode(((col-1)%26) + 65) + s; return s; } ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#1244
No description provided.