Skip to content

Commit 2cd36ad

Browse files
committed
- This to fix MDEV-7498. All changes made to AllocateValue to be sure 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
1 parent dc091a2 commit 2cd36ad

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

storage/connect/tabjson.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,15 @@ bool JSONCOL::ParseJpath(PGLOBAL g)
507507

508508
if (Parsed)
509509
return false; // Already done
510-
else if (InitValue(g))
510+
511+
if (InitValue(g))
512+
return true;
513+
else
514+
MulVal = Value;
515+
516+
Value = NULL;
517+
518+
if (InitValue(g))
511519
return true;
512520
else if (!Jpath)
513521
Jpath = Name;
@@ -540,7 +548,6 @@ bool JSONCOL::ParseJpath(PGLOBAL g)
540548

541549
} // endfor i, p
542550

543-
MulVal = AllocateValue(g, Value);
544551
Parsed = true;
545552
return false;
546553
} // end of ParseJpath

storage/connect/value.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,20 +436,18 @@ PVAL AllocateValue(PGLOBAL g, PVAL valp, int newtype, int uns)
436436
bool un = (uns < 0) ? false : (uns > 0) ? true : valp->IsUnsigned();
437437
PVAL vp;
438438

439+
if (!valp)
440+
return NULL;
441+
439442
if (newtype == TYPE_VOID) // Means allocate a value of the same type
440443
newtype = valp->GetType();
441444

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

446-
if ((sp = valp->GetCharString(p)) != p) {
447-
if (sp)
448-
strcpy (p, sp);
449-
else
450-
*p = 0;
451-
452-
} // endif sp
449+
if ((sp = valp->GetCharString(p)) != p)
450+
strcpy(p, sp);
453451

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

0 commit comments

Comments
 (0)