Re: [xml] debugging outputbuffer code in libxml



[clipped]

One interesting thing I noticed when debugging was in encoding.c
xmlCharEncOutFunc, or to be more specific the following code:

retry:

    written = out->size - out->use;

    /*
     * First specific handling of in = NULL, i.e. the initialization call
     */
    if (in == NULL) {
        toconv = 0;
        if (handler->output != NULL) {
            ret = handler->output(&out->content[out->use], &written,
                                  NULL, &toconv);
            out->use += written;
            out->content[out->use] = 0;
        }

[clipped]

Here is a little fix that seems to fix the random garbage from appearing
in the output.
I have changed the above code to look something like:

retry:
 
     written = out->size - out->use;
 
     /*
      * First specific handling of in = NULL, i.e. the initialization
call
      */
     if (in == NULL) {
         toconv = 0;
         if (handler->output != NULL) {
             ret = handler->output(&out->content[out->use], &written,
                                   NULL, &toconv);
             
             if (ret >= 0) {
                out->use += written;
                out->content[out->use] = 0;
             }
         }

P.S. There are a few more things that need to be fixed, and I hope to
have those figured out on Monday (unless I manage to somehow debug this
at home)

G.F. aka Gena01
http://www.gena01.com



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