diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2013-07-25 19:09:46 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2013-07-25 19:09:46 +0200 |
commit | 1c5c2c6db99e383f2cc924267cbf00e6ff741fb5 (patch) | |
tree | 0484f6e0863a93967fc771fc415e22cfdc34dd57 /storage | |
parent | 319414398fd445af25c007be3c7502c87bf51d5c (diff) | |
download | mariadb-git-1c5c2c6db99e383f2cc924267cbf00e6ff741fb5.tar.gz |
- 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
Diffstat (limited to 'storage')
-rw-r--r-- | storage/connect/tabutil.cpp | 8 | ||||
-rw-r--r-- | storage/connect/value.cpp | 30 |
2 files changed, 26 insertions, 12 deletions
diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp index 6e5f6784d3a..6f1305f476c 100644 --- a/storage/connect/tabutil.cpp +++ b/storage/connect/tabutil.cpp @@ -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); diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index e75a6e41557..4e8c6a74170 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -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 { |