Hi I believe there is a minor bug in the function pj_xml_print( ... ) I assume that the intention is that -1 should be returned if the buffer is not large enough when printing the xml nodes with xml_print_node(...) However if a prolog is used this can never happen since the prolog_len is added after the recursive function: printed = xml_print_node(node, 0, buf+prolog_len, len-prolog_len) + prolog_len; If xml_print_node returns -1 due to a non sufficient buffer the result will be 39 anyway which is ((-1 + prolog_len) + the terminating \n added on the line below). Best Regards Johan Lantz