From 837a2bbdde28986d917eb1081bbe7e62a0dfdf4c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 21 Aug 2020 17:59:46 -0500 Subject: [PATCH] const init a char array from a string value Conflicts: documentation/RELEASE_NOTES.md --- modules/database/src/std/link/lnkConst.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/database/src/std/link/lnkConst.c b/modules/database/src/std/link/lnkConst.c index cc443e0ba..93ac1c40f 100644 --- a/modules/database/src/std/link/lnkConst.c +++ b/modules/database/src/std/link/lnkConst.c @@ -488,8 +488,17 @@ static long lnkConst_loadArray(struct link *plink, short dbrType, void *pbuffer, case sc40: if (clink->jlink.debug) printf(" sc40 '%s'\n", clink->value.scalar_string); - status = dbFastPutConvertRoutine[DBF_STRING][dbrType] - (clink->value.scalar_string, pbuffer, NULL); + if (dbrType != DBF_CHAR) { + status = dbFastPutConvertRoutine[DBF_STRING][dbrType] + (clink->value.scalar_string, pbuffer, NULL); + } + else { + /* Long string conversion */ + strncpy(pbuffer, clink->value.scalar_string, *pnReq); + ((char *)pbuffer)[*pnReq] = 0; + nElems = strlen(pbuffer) + 1; + status = 0; + } break; case ai64: