Skip to content
Snippets Groups Projects
  • Nika Layzell's avatar
    aef919f8
    Bug 1170668 - Improve short read handling in nsConverterInputStream, r=hsivonen · aef919f8
    Nika Layzell authored
    This patch changes how nsConverterInputStream handles passing data
    through to the underlying unicode converter in order to make it more
    reliably handle propagating errors and deal with short reads from the
    underlying input stream.
    
    This was done by making the code continuously read within the Fill
    method until at least one character has been decoded from the input
    stream, so that we don't spuriously communicate an EOF to the caller due
    to a short read not producing enough bytes for the decoder to produce a
    UTF-16 character.
    
    In addition, while making this change it became easier to signal to
    the decoder about the final read from the input stream, meaning that
    partial characters at the end of the stream will now generate a
    replacement character, rather than being ignored.
    
    Differential Revision: https://phabricator.services.mozilla.com/D152682
    aef919f8
    History
    Bug 1170668 - Improve short read handling in nsConverterInputStream, r=hsivonen
    Nika Layzell authored
    This patch changes how nsConverterInputStream handles passing data
    through to the underlying unicode converter in order to make it more
    reliably handle propagating errors and deal with short reads from the
    underlying input stream.
    
    This was done by making the code continuously read within the Fill
    method until at least one character has been decoded from the input
    stream, so that we don't spuriously communicate an EOF to the caller due
    to a short read not producing enough bytes for the decoder to produce a
    UTF-16 character.
    
    In addition, while making this change it became easier to signal to
    the decoder about the final read from the input stream, meaning that
    partial characters at the end of the stream will now generate a
    replacement character, rather than being ignored.
    
    Differential Revision: https://phabricator.services.mozilla.com/D152682