1.7.2 Scratchpad file corrupted

This morning I loaded Scrivener, and found that when I went into the Scratchpad, it was sometimes slow to switch between documents. Then, at a certain point, it hung up for a minute, and then Scrivener just closed entirely; it started allocating memory like crazy, got close to 2 GB, and then started unloading everything and vanished.

I traced this to a corrupt RTF file in my Scratchpad folder. If I load this RTF file into Word and re-save it, it drops down from 87K to 37K and then Scrivener can open it without trouble.

I’m thinking that for some reason, Scrivener started fiddling with this file (I haven’t really been touching it) and gradually got it to a threshold that broke something in Scrivener.

What I noticed is that this RTF file has some long stretches of the \tx360 RTF code. Here’s what one line in the RTF file looks like:

\par\pard\plain \tx360\tx360 ... [many more \tx360s] ... \tx360\tx360\qj\f1\fs24\b0\i0 ]}}

That line is 49226 characters long! I don’t think it has any actual user data except for the closing square bracket. Also, a few lines earlier I have another line that looks like this:

\par\pard\plain \tx360 ... [many more \tx360s] ... \tx360\qj\f1\fs24\b0\i0 [TODO: (a note of mine)
This line is 37042 characters long.

Not sure if this is something to do with the square brackets. They’ve never caused me problems before with Scrivener.

At any rate, my guess is that one bug in Scrivener caused this to get written to like this with this junk, and that there’s a separate buffer overrun bug that results in an infinite loop memory allocation or some such.

I have taken the corrupt file, removed most of the text (or replaced it), verified it still crashes Scrivener, and attached it.
test corrupt file.zip (725 Bytes)