cinera.c: Fix segfault in CurlIntoBuffer()
This was caused by trying to read InPtr[i] before checking if i < Length in the loop's header. An -O2 build didn't exhibit the bug, but an -Od one had begun to since I'd last run a debug build. Also upped the sizes of the PlayerBuffers' Menus and Main buffers.
This commit is contained in:
parent
14dafa4abe
commit
a67a5ee34b
|
@ -8431,15 +8431,10 @@ String0ToInt(char *String)
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
CurlIntoBuffer(char *InPtr, size_t CharLength, size_t Chars, char **OutputPtr)
|
CurlIntoBuffer(char *InPtr, size_t CharLength, size_t Chars, void *OutPtr)
|
||||||
{
|
{
|
||||||
int Length = CharLength * Chars;
|
size_t Length = CharLength * Chars;
|
||||||
int i;
|
CopyStringToBufferNoFormat(OutPtr, Wrap0i_(InPtr, Length));
|
||||||
for(i = 0; InPtr[i] && i < Length; ++i)
|
|
||||||
{
|
|
||||||
*((*OutputPtr)++) = InPtr[i];
|
|
||||||
}
|
|
||||||
**OutputPtr = '\0';
|
|
||||||
return Length;
|
return Length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8452,7 +8447,7 @@ CurlQuotes(buffer *QuoteStaging, char *QuotesURL)
|
||||||
|
|
||||||
CURL *curl = curl_easy_init();
|
CURL *curl = curl_easy_init();
|
||||||
if(curl) {
|
if(curl) {
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &QuoteStaging->Ptr);
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, QuoteStaging);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlIntoBuffer);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, CurlIntoBuffer);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, QuotesURL);
|
curl_easy_setopt(curl, CURLOPT_URL, QuotesURL);
|
||||||
/* */ MEM_TEST_MID();
|
/* */ MEM_TEST_MID();
|
||||||
|
@ -10654,8 +10649,8 @@ ClaimMenuIndexAndPlayerBuffers(menu_buffers *MenuBuffers, index_buffers *IndexBu
|
||||||
if(ClaimBuffer(&IndexBuffers->Text, BID_INDEX_BUFFERS_TEXT, Kilobytes(4)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
if(ClaimBuffer(&IndexBuffers->Text, BID_INDEX_BUFFERS_TEXT, Kilobytes(4)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
||||||
if(ClaimBuffer(&IndexBuffers->CategoryIcons, BID_INDEX_BUFFERS_CATEGORY_ICONS, Kilobytes(1)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
if(ClaimBuffer(&IndexBuffers->CategoryIcons, BID_INDEX_BUFFERS_CATEGORY_ICONS, Kilobytes(1)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
||||||
|
|
||||||
if(ClaimBuffer(&PlayerBuffers->Menus, BID_PLAYER_BUFFERS_MENUS, Kilobytes(32)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
if(ClaimBuffer(&PlayerBuffers->Menus, BID_PLAYER_BUFFERS_MENUS, Kilobytes(64)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
||||||
if(ClaimBuffer(&PlayerBuffers->Main, BID_PLAYER_BUFFERS_MAIN, Kilobytes(512)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
if(ClaimBuffer(&PlayerBuffers->Main, BID_PLAYER_BUFFERS_MAIN, Megabytes(1)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
||||||
if(ClaimBuffer(&PlayerBuffers->Script, BID_PLAYER_BUFFERS_SCRIPT, Kilobytes(8)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
if(ClaimBuffer(&PlayerBuffers->Script, BID_PLAYER_BUFFERS_SCRIPT, Kilobytes(8)) == RC_ARENA_FULL) { Result = RC_ARENA_FULL; };
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
|
|
Loading…
Reference in New Issue