X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/5bc2777230cdc4cea23ff87df356af3fb0cfadf9..366cc6fc4c7bf1eed47cc9b52d0ef809b2e90174:/sbr/fmt_scan.c diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index cb29b72c..f9aee54b 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -247,9 +247,9 @@ static void cpstripped (charstring_t dest, size_t max, char *str) { static bool deja_vu; - static char *oddchar; + static char oddchar[MB_LEN_MAX * 2]; static size_t oddlen; - static char *spacechar; + static char spacechar[MB_LEN_MAX * 2]; static size_t spacelen; char *end; bool squash; @@ -259,19 +259,12 @@ cpstripped (charstring_t dest, size_t max, char *str) int w; if (!deja_vu) { - size_t two; - deja_vu = true; - two = MB_CUR_MAX * 2; /* Varies at run-time. */ - - oddchar = mh_xmalloc(two); - oddlen = wcstombs(oddchar, L"?", two); + oddlen = wcstombs(oddchar, L"?", sizeof oddchar); assert(oddlen > 0); - assert(wcwidth(L' ') == 1); /* Need to pad in ones. */ - spacechar = mh_xmalloc(two); - spacelen = wcstombs(spacechar, L" ", two); + spacelen = wcstombs(spacechar, L" ", sizeof spacechar); assert(spacelen > 0); } @@ -1155,7 +1148,11 @@ fmt_scan (struct format *format, charstring_t scanlp, int width, int *dat, comp->c_mn will be run through FT_LS_ADDR, which will strip off any pers name. */ - free (comp->c_text); + /* NB: We remove the call to free() here + because it interferes with the buffer + management in scansbr.c. Revisit this + when we clean up memory handling */ + /* free (comp->c_text); */ comp->c_text = str = strdup (mn->m_text); comp->c_mn = mn; }