Skip to content

Commit 1af7c4c

Browse files
committed
Fixes static analyzer issues from xcode.
1 parent 4f379f8 commit 1af7c4c

File tree

5 files changed

+7
-4
lines changed

5 files changed

+7
-4
lines changed

src/google/protobuf/compiler/parser.cc

+1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ bool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {
570570

571571
input_ = NULL;
572572
source_code_info_ = NULL;
573+
assert(file != NULL);
573574
source_code_info.Swap(file->mutable_source_code_info());
574575
return !had_errors_;
575576
}

src/google/protobuf/stubs/substitute.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ void SubstituteAndAppend(
113113
for (int i = 0; format[i] != '\0'; i++) {
114114
if (format[i] == '$') {
115115
if (ascii_isdigit(format[i+1])) {
116-
const SubstituteArg* src = args_array[format[i+1] - '0'];
116+
unsigned int index = format[i+1] - '0';
117+
assert(index < 10);
118+
const SubstituteArg* src = args_array[index];
117119
memcpy(target, src->data(), src->size());
118120
target += src->size();
119121
++i; // Skip next char.

src/google/protobuf/util/internal/default_value_objectwriter.cc

-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ void DefaultValueObjectWriter::RenderDataPiece(StringPiece name,
586586
new Node(name.ToString(), NULL, PRIMITIVE, data, false,
587587
child == NULL ? current_->path() : child->path(),
588588
suppress_empty_list_, field_scrub_callback_.get()));
589-
child = node.get();
590589
current_->AddChild(node.release());
591590
} else {
592591
child->set_data(data);

src/google/protobuf/util/internal/json_stream_parser.cc

-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ util::Status JsonStreamParser::ParseStringHelper() {
315315
// We're about to handle an escape, copy all bytes from last to data.
316316
if (last < data) {
317317
parsed_storage_.append(last, data - last);
318-
last = data;
319318
}
320319
// If we ran out of string after the \, cancel or report an error
321320
// depending on if we expect more data later.
@@ -371,7 +370,6 @@ util::Status JsonStreamParser::ParseStringHelper() {
371370
} else {
372371
if (last < data) {
373372
parsed_storage_.append(last, data - last);
374-
last = data;
375373
}
376374
parsed_ = StringPiece(parsed_storage_);
377375
}

src/google/protobuf/util/message_differencer.cc

+3
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ bool MessageDifferencer::CompareWithFieldsInternal(
626626
}
627627

628628
if (reporter_ != NULL) {
629+
assert(field1 != NULL);
629630
int count = field1->is_repeated() ?
630631
reflection1->FieldSize(message1, field1) : 1;
631632

@@ -706,6 +707,7 @@ bool MessageDifferencer::CompareWithFieldsInternal(
706707
}
707708

708709
bool fieldDifferent = false;
710+
assert(field1 != NULL);
709711
if (field1->is_repeated()) {
710712
fieldDifferent = !CompareRepeatedField(message1, message2, field1,
711713
parent_fields);
@@ -875,6 +877,7 @@ bool MessageDifferencer::CompareRepeatedField(
875877

876878
for (int i = 0; i < count1; ++i) {
877879
if (match_list1[i] != -1) continue;
880+
assert(reporter_ != NULL);
878881
specific_field.index = i;
879882
parent_fields->push_back(specific_field);
880883
reporter_->ReportDeleted(message1, message2, *parent_fields);

0 commit comments

Comments
 (0)