poppler/Error.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
New commits: commit 7e0bf20c1aa7859565b0c6d3b1f78efcce949617 Author: Albert Astals Cid <[email protected]> Date: Thu Feb 10 11:15:11 2022 +0100 Error: Save newing/deleting a GooString diff --git a/poppler/Error.cc b/poppler/Error.cc index 25a1af67..855806e7 100644 --- a/poppler/Error.cc +++ b/poppler/Error.cc @@ -47,7 +47,7 @@ void setErrorCallback(ErrorCallback cbk) void CDECL error(ErrorCategory category, Goffset pos, const char *msg, ...) { va_list args; - GooString *s, *sanitized; + GooString *s; // NB: this can be called before the globalParams object is created if (!errorCbk && globalParams && globalParams->getErrQuiet()) { @@ -57,26 +57,25 @@ void CDECL error(ErrorCategory category, Goffset pos, const char *msg, ...) s = GooString::formatv(msg, args); va_end(args); - sanitized = new GooString(); + GooString sanitized; for (int i = 0; i < s->getLength(); ++i) { const char c = s->getChar(i); if (c < (char)0x20 || c >= (char)0x7f) { - sanitized->appendf("<{0:02x}>", c & 0xff); + sanitized.appendf("<{0:02x}>", c & 0xff); } else { - sanitized->append(c); + sanitized.append(c); } } if (errorCbk) { - (*errorCbk)(category, pos, sanitized->c_str()); + (*errorCbk)(category, pos, sanitized.c_str()); } else { if (pos >= 0) { - fprintf(stderr, "%s (%lld): %s\n", errorCategoryNames[category], (long long)pos, sanitized->c_str()); + fprintf(stderr, "%s (%lld): %s\n", errorCategoryNames[category], (long long)pos, sanitized.c_str()); } else { - fprintf(stderr, "%s: %s\n", errorCategoryNames[category], sanitized->c_str()); + fprintf(stderr, "%s: %s\n", errorCategoryNames[category], sanitized.c_str()); } fflush(stderr); } delete s; - delete sanitized; }
