Currently we are doing something illegal if iconv fails (creating a vector 
from two pointers, where the end is before the start). That throws a 
std::bad_alloc exception in my environment.
What do we want to do? The attached patch simply returns an empty string, but 
I am not sure whether that is what we want. We could also throw an exception 
and handle that in the caller. What do others think?


Georg
Index: src/support/unicode.C
===================================================================
--- src/support/unicode.C	(Revision 16404)
+++ src/support/unicode.C	(Arbeitskopie)
@@ -203,6 +203,9 @@
 	char * outbuf = out;
 
 	int bytes = processor.convert(inbuf, inbytesleft, outbuf, outsize);
+	if (bytes <= 0)
+		// Conversion failed
+		return std::vector<RetType>();
 
 	RetType const * tmp = reinterpret_cast<RetType const *>(out);
 	return std::vector<RetType>(tmp, tmp + bytes / sizeof(RetType));

Reply via email to