Skip to content

Commit

Permalink
Fix uninitialized value for 'size'
Browse files Browse the repository at this point in the history
  • Loading branch information
peadar committed Jul 9, 2024
1 parent 145c2c5 commit a56577d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,20 +405,23 @@ struct RemoteValue {
buf.resize(sizeof addr_);
memcpy(&buf[0], &addr_, sizeof addr_);
} else {
size_t size;
auto sizeAttr = type.attribute(DW_AT_byte_size);
size_t size;
if (sizeAttr.valid()) {
size = uintmax_t(sizeAttr);
} else if (type.tag() == DW_TAG_reference_type || type.tag() == DW_TAG_pointer_type) {
size = sizeof (void *);
} else {
size = 0;
}
if (!size) {
error = "<no size for type>";
}
buf.resize(size);
auto rc = p.io->read(addr, size, &buf[0]);
if (rc != size) {
error = "<failed to read from remote>";
} else {
buf.resize(size);
auto rc = p.io->read(addr, size, &buf[0]);
if (rc != size) {
error = "<failed to read from remote>";
}
}
}
}
Expand Down

0 comments on commit a56577d

Please sign in to comment.