Commit 1c5c2c6d authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix a few test in TYPVAL<PSZ> that cause Valgrind warnings

modified:
  storage/connect/value.cpp

- Ignore column comment field in TabColumns because its pointer is flagged
  as invalid by Valgrind (this is a bypass but not a real fix)

modified:
  storage/connect/tabutil.cpp
  storage/connect/value.cpp
parent 31941439
......@@ -226,8 +226,12 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
crp->Kdata->SetValue((fp->null_ptr != 0) ? 1 : 0, i);
crp = crp->Next; // Remark
fld = fp->comment.str;
crp->Kdata->SetValue(fld, fp->comment.length, i);
// For Valgrind until bug on comment storage is fixed
// if (fp->comment.length > 0 && (fld = fp->comment.str))
// crp->Kdata->SetValue(fld, fp->comment.length, i);
// else
crp->Kdata->Reset(i);
crp = crp->Next; // New
crp->Kdata->SetValue((fmt) ? fmt : (char*) "", i);
......
......@@ -871,12 +871,16 @@ TYPVAL<PSZ>::TYPVAL(PSZ s) : VALUE(TYPE_STRING)
TYPVAL<PSZ>::TYPVAL(PGLOBAL g, PSZ s, int n, int c)
: VALUE(TYPE_STRING)
{
assert(Type == TYPE_STRING && (g || s));
assert(Type == TYPE_STRING);
Len = (g) ? n : strlen(s);
if (g && !s) {
Strp = (char *)PlugSubAlloc(g, NULL, Len + 1);
Strp[Len] = '\0';
if (!s) {
if (g) {
Strp = (char *)PlugSubAlloc(g, NULL, Len + 1);
Strp[Len] = '\0';
} else
assert(false);
} else
Strp = s;
......@@ -908,15 +912,21 @@ bool TYPVAL<PSZ>::SetValue_pval(PVAL valp, bool chktype)
void TYPVAL<PSZ>::SetValue_char(char *p, int n)
{
if (p) {
n = min(n, Len);
strncpy(Strp, p, n);
if ((n = min(n, Len))) {
strncpy(Strp, p, n);
for (p = Strp + n - 1; (*p == ' ' || *p == '\0') && p >= Strp; p--) ;
// for (p = Strp + n - 1; p >= Strp && (*p == ' ' || *p == '\0'); p--) ;
for (p = Strp + n - 1; p >= Strp; p--)
if (*p && *p != ' ')
break;
*(++p) = '\0';
*(++p) = '\0';
if (trace > 1)
htrc(" Setting string to: '%s'\n", Strp);
if (trace > 1)
htrc(" Setting string to: '%s'\n", Strp);
} else
Reset();
Null = false;
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment