Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[squash] comments
  • Loading branch information
addaleax committed Feb 9, 2018
commit ebf70eb95164e0b8a673e00bfb7b39896a1eb6a8
14 changes: 7 additions & 7 deletions src/string_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ MaybeLocal<String> MakeString(Isolate* isolate,

MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
const char* data,
ssize_t* nread_ptr) {
size_t* nread_ptr) {
Local<String> prepend, body;

size_t nread = *nread_ptr;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nread_ptr should probably be a size_t* (see comment further down) but otherwise do a CHECK_GE(*nread_ptr, 0) sanity check first.

Expand Down Expand Up @@ -150,7 +150,7 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
#endif
state_[kBufferedBytes]++;
if ((data[i] & 0xC0) == 0x80) {
// This byte does not start a character (a "trailing" bytes).
// This byte does not start a character (a "trailing" byte).
if (state_[kBufferedBytes] >= 4 || i == 0) {
// We either have more then 4 trailing bytes (which means
// the current character would not be inside the range for
Expand Down Expand Up @@ -223,11 +223,11 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
}
}

if (!prepend.IsEmpty()) {
if (prepend.IsEmpty()) {
return body;
} else {
return String::Concat(prepend, body);
}

return body;
} else {
CHECK(Encoding() == ASCII || Encoding() == HEX || Encoding() == LATIN1);
return MakeString(isolate, data, nread, Encoding());
Expand All @@ -240,7 +240,7 @@ MaybeLocal<String> StringDecoder::FlushData(Isolate* isolate) {
CHECK_EQ(BufferedBytes(), 0);
}

if (Encoding() == UCS2 && (BufferedBytes() % 2) == 1) {
if (Encoding() == UCS2 && BufferedBytes() % 2 == 1) {
// Ignore a single trailing byte, like the JS decoder does.
state_[kMissingBytes]--;
state_[kBufferedBytes]--;
Expand All @@ -267,7 +267,7 @@ void DecodeData(const FunctionCallbackInfo<Value>& args) {
StringDecoder* decoder =
reinterpret_cast<StringDecoder*>(Buffer::Data(args[0]));
CHECK_NE(decoder, nullptr);
ssize_t nread = Buffer::Length(args[1]);
size_t nread = Buffer::Length(args[1]);
MaybeLocal<String> ret =
decoder->DecodeData(args.GetIsolate(), Buffer::Data(args[1]), &nread);
if (!ret.IsEmpty())
Expand Down
2 changes: 1 addition & 1 deletion src/string_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StringDecoder {
// was finished.
v8::MaybeLocal<v8::String> DecodeData(v8::Isolate* isolate,
const char* data,
ssize_t* nread);
size_t* nread);
// Flush an incomplete character. For character encodings like UTF8 this
// means printing replacement characters, buf for e.g. Base64 the returned
// string contains more data.
Expand Down