1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Fixes from review by @Hoikas

This commit is contained in:
2013-01-05 20:04:55 -08:00
parent 2382cebd11
commit 58a8034eb7
3 changed files with 8 additions and 48 deletions

View File

@ -185,46 +185,6 @@ static inline void ICopyString (wchar_t ** plhs, const wchar_t rhs[]) {
*plhs = StrDup(L"");
}
//============================================================================
template <typename T>
static bool IStrSqlEscape (const T src[], T * dst, unsigned dstChars) {
// count the number of ' chars
unsigned ticks = 0;
{
const T * cur = src;
while (*cur) {
if (*cur == L'\'')
++ticks;
cur++;
}
}
unsigned reqChars = StrLen(src) + ticks + 1;
if (dstChars < reqChars)
// failure!
return false;
T * cur = dst;
// copy src to dst, escaping ' chars
while (*src) {
if (*src == L'\'') {
*cur++ = L'\'';
*cur++ = *src++;
continue;
}
*cur++ = *src++;
}
// null-terminate dst string
*cur = 0;
// success!
return true;
}
} using namespace pnNpCommon;