diff --git a/src/db/dbTest.c b/src/db/dbTest.c index 587b1df23..ed0111a69 100644 --- a/src/db/dbTest.c +++ b/src/db/dbTest.c @@ -950,7 +950,9 @@ static void printBuffer( } else { for (i = 0; i < no_elements; i+= MAXLINE - 5) { - sprintf(pmsg, " \"%.*s\"", MAXLINE - 5, (char *)pbuffer + i); + int width = no_elements - i; + if (width > MAXLINE - 5) width = MAXLINE - 5; + sprintf(pmsg, " \"%.*s\"", width, (char *)pbuffer + i); if (i + MAXLINE - 5 < no_elements) strcat(pmsg, " +"); dbpr_msgOut(pMsgBuff, tab_size); }