From 6bd9760f3b3a8168d3a8bc240533a56162cb97da Mon Sep 17 00:00:00 2001 From: david Date: Mon, 24 Aug 2009 18:10:12 +0000 Subject: [PATCH] In xml_convert, handle the case when repl is the empty string on the first iteration. This can't happen with the current data definitions, but if it did it would result in memcpy being passed a null pointer. (memcpy would be asked to do a zero-byte copy, so it would probably be okay anyway, but it's better to be safe.) --- output.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/output.cc b/output.cc index b39d400af..73c4323ce 100644 --- a/output.cc +++ b/output.cc @@ -912,7 +912,7 @@ char *xml_convert(const char *str) { len = strlen(repl); /* Double the size of the result buffer if necessary. */ - if (i + len > n) { + if (i == 0 || i + len > n) { n = (i + len) * 2; result = (char *) safe_realloc(result, n + 1); }