- *buf_out = (char*) odr_malloc(o, *len_out);
- memcpy(*buf_out, wrbuf_buf(m_wrbuf), *len_out);
+ if (*len_out == 0)
+ { // we assume conversion failed
+ *buf_out = buf_in;
+ *len_out = len_in;
+ }
+ else
+ {
+ *buf_out = (char*) odr_malloc(o, *len_out);
+ memcpy(*buf_out, wrbuf_buf(m_wrbuf), *len_out);
+ }