Skip to content

Commit a2de604

Browse files
committed
ASAN error in CONNECT engine
don't strcpy a string to itself
1 parent 2ed882f commit a2de604

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

storage/connect/value.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,12 @@ int TYPVAL<PSZ>::CompareValue(PVAL vp)
16271627
return (n > 0) ? 1 : (n < 0) ? -1 : 0;
16281628
} // end of CompareValue
16291629

1630+
static inline void v_strcpy(char *dest, const char *src)
1631+
{
1632+
if (dest != src)
1633+
strcpy(dest, src);
1634+
}
1635+
16301636
/***********************************************************************/
16311637
/* Compute a function on a string. */
16321638
/***********************************************************************/
@@ -1651,11 +1657,11 @@ bool TYPVAL<PSZ>::Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op)
16511657
break;
16521658
case OP_MIN:
16531659
assert(np == 2);
1654-
strcpy(Strp, (strcmp(p[0], p[1]) < 0) ? p[0] : p[1]);
1660+
v_strcpy(Strp, (strcmp(p[0], p[1]) < 0) ? p[0] : p[1]);
16551661
break;
16561662
case OP_MAX:
16571663
assert(np == 2);
1658-
strcpy(Strp, (strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
1664+
v_strcpy(Strp, (strcmp(p[0], p[1]) > 0) ? p[0] : p[1]);
16591665
break;
16601666
default:
16611667
// sprintf(g->Message, MSG(BAD_EXP_OPER), op);

0 commit comments

Comments
 (0)