Skip to content

Commit

Permalink
- This to fix MDEV-7498. All changes made to AllocateValue to be sure…
Browse files Browse the repository at this point in the history
… that

  the sp and p variable be initialised failed. Not understanding what causes
  this valgrind warning, I finally changed the way Mulval is allocated just
  to avoid it. This is a BAD solution as it does not really fix the problem
  but just hide it. This will have to be re-considered.
modified:
  storage/connect/tabjson.cpp
  storage/connect/value.cpp
  • Loading branch information
Buggynours committed Jan 23, 2015
1 parent dc091a2 commit 2cd36ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 9 additions & 2 deletions storage/connect/tabjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,15 @@ bool JSONCOL::ParseJpath(PGLOBAL g)

if (Parsed)
return false; // Already done
else if (InitValue(g))

if (InitValue(g))
return true;
else
MulVal = Value;

Value = NULL;

if (InitValue(g))
return true;
else if (!Jpath)
Jpath = Name;
Expand Down Expand Up @@ -540,7 +548,6 @@ bool JSONCOL::ParseJpath(PGLOBAL g)

} // endfor i, p

MulVal = AllocateValue(g, Value);
Parsed = true;
return false;
} // end of ParseJpath
Expand Down
12 changes: 5 additions & 7 deletions storage/connect/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,20 +436,18 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
bool un = (uns < 0) ? false : (uns > 0) ? true : valp->IsUnsigned();
PVAL vp;

if (!valp)
return NULL;

if (newtype == TYPE_VOID) // Means allocate a value of the same type
newtype = valp->GetType();

switch (newtype) {
case TYPE_STRING:
p = (PSZ)PlugSubAlloc(g, NULL, 1 + valp->GetValLen());

if ((sp = valp->GetCharString(p)) != p) {
if (sp)
strcpy (p, sp);
else
*p = 0;

} // endif sp
if ((sp = valp->GetCharString(p)) != p)
strcpy(p, sp);

vp = new(g) TYPVAL<PSZ>(g, p, valp->GetValLen(), valp->GetValPrec());
break;
Expand Down

0 comments on commit 2cd36ad

Please sign in to comment.