Fix over-eager MSVCRT bounds checking crash in LuaTCPSocket

MSVCRT doesn't like .operator[](.size()), it's safer to just replace all &.operator[x] with &.operator[0]+x.
This commit is contained in:
Tamás Bálint Misius
2021-06-24 07:09:58 +02:00
parent fb514ca9e3
commit 72948978fa

View File

@@ -205,7 +205,7 @@ namespace LuaTCPSocket
CURLcode res = CURLE_OK; CURLcode res = CURLE_OK;
if (!tcps->writeClosed) if (!tcps->writeClosed)
{ {
res = curl_easy_send(tcps->easy, &data[writtenTotal], len - writtenTotal, &writtenNow); res = curl_easy_send(tcps->easy, &data[0] + writtenTotal, len - writtenTotal, &writtenNow);
} }
writtenTotal += writtenNow; writtenTotal += writtenNow;
if (writtenTotal >= len) if (writtenTotal >= len)
@@ -299,7 +299,7 @@ namespace LuaTCPSocket
} }
else else
{ {
res = curl_easy_recv(tcps->easy, &tcps->recvBuf[readTotal], len - readTotal, &readNow); res = curl_easy_recv(tcps->easy, &tcps->recvBuf[0] + readTotal, len - readTotal, &readNow);
} }
readTotal += readNow; readTotal += readNow;
returning = readTotal; returning = readTotal;
@@ -410,8 +410,8 @@ namespace LuaTCPSocket
// of view of an "*l" pattern). Handling this edge case in a special, // of view of an "*l" pattern). Handling this edge case in a special,
// sub-quadratic way isn't worth the effort. // sub-quadratic way isn't worth the effort.
std::copy( std::copy(
&tcps->recvBuf[readTotal - tcps->stashedLen], &tcps->recvBuf[0] + readTotal - tcps->stashedLen,
&tcps->recvBuf[readTotal], &tcps->recvBuf[0] + readTotal,
&tcps->recvBuf[0] &tcps->recvBuf[0]
); );
return retn; return retn;