String createInternal failing

Jules, I’m using a filelogger, and running into problems when the log gets too big. This:

[code]void String::createInternal (const int numChars) throw()
{
jassert (numChars > 0);

text = (InternalRefCountedStringHolder*) juce_malloc (sizeof (InternalRefCountedStringHolder)
                                                       + numChars * sizeof (tchar));
text->refCount = 1;
text->allocatedNumChars = numChars;
text->text[0] = 0;

}
[/code]

Throws an exception when text comes out NULL, with a file size of 1040012127. It’s less than an int, but it gets multiplied by a tchar - how big is that? If it’s bigger than 3, we’re busting the int barrier, so that may be it. Seems unlikely it’s memory.

Not that it matters, but this is all in the file-logger opening the log to truncate it.

As a stop gap, I’m trying something like:

if (text == NULL) // stop gap text = (InternalRefCountedStringHolder*) juce_malloc (sizeof(int));

I’d guess you have a better fix?

Bruce