Re: [xml] xmlTextWriterWriteFormatElement problem

James Eggleston wrote:

const int longStringLength(8192); // 8192 causes a seg fault... // const int longStringLength(8191); // 8191doesn't cause a problem!
#0 0x0000002a95d2bd70 in strlen () from /lib64/tls/ #1 0x0000002a95cffcdc in vfprintf () from /lib64/tls/ #2 0x0000002a95d1f337 in vsnprintf () from /lib64/tls/ #3 0x0000002a95735fc1 in xmlTextWriterVSprintf () from /usr/lib64/ #4 0x0000002a95738e1e in xmlTextWriterWriteVFormatElement () from /usr/lib64/ #5 0x0000002a95738ee3 in xmlTextWriterWriteFormatElement () from /usr/lib64/ #6 0x000000000040096c in main () Does anyone have any ideas why this is and if anything can be done?

I am not able to reproduce your problem, but I do have an idea about
what is wrong.

xmlTextWriterVSprintf() allocates BUFSIZ bytes, and BUFSIZ is probably
8192 (it is on my machine). The problem appear to be that this function
does not allocate one extra byte for the terminating zero.

The easiest way to solve this problem is to pass 'size - 1' rather than
'size' as the second parameter to vsnprintf().

Could you try to make that change and see if it work?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]