RemoteFortressReader: Fix a possible null pointer access on image descriptions

develop
plule 2023-06-10 21:31:35 +02:00
parent a487e98913
commit c55ab745bb
3 changed files with 9 additions and 3 deletions

@ -37,6 +37,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Fixes ## Fixes
- `dig-now`: clear item occupancy flags for channeled tiles that had items on them - `dig-now`: clear item occupancy flags for channeled tiles that had items on them
- `RemoteFortressReader`: fix a crash with engraving without image
## Misc Improvements ## Misc Improvements
- `autonick`: additional nicknames based on burrowing animals, colours, gems and minerals added - `autonick`: additional nicknames based on burrowing animals, colours, gems and minerals added

@ -248,7 +248,7 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
chunk = world->art_image_chunks[i]; chunk = world->art_image_chunks[i];
} }
} }
if (chunk) if (chunk && chunk->images[statue->image.subid])
{ {
CopyImage(chunk->images[statue->image.subid], NetItem->mutable_image()); CopyImage(chunk->images[statue->image.subid], NetItem->mutable_image());
} }
@ -462,7 +462,10 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
case df::enums::improvement_type::ART_IMAGE: case df::enums::improvement_type::ART_IMAGE:
{ {
VIRTUAL_CAST_VAR(artImage, df::itemimprovement_art_imagest, improvement); VIRTUAL_CAST_VAR(artImage, df::itemimprovement_art_imagest, improvement);
CopyImage(artImage->getImage(DfItem), netImp->mutable_image()); auto image = artImage->getImage(DfItem);
if (image) {
CopyImage(image, netImp->mutable_image());
}
break; break;
} }
case df::enums::improvement_type::COVERED: case df::enums::improvement_type::COVERED:

@ -1530,7 +1530,9 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
ConvertDFCoord(engraving->pos, netEngraving->mutable_pos()); ConvertDFCoord(engraving->pos, netEngraving->mutable_pos());
netEngraving->set_quality(engraving->quality); netEngraving->set_quality(engraving->quality);
netEngraving->set_tile(engraving->tile); netEngraving->set_tile(engraving->tile);
CopyImage(chunk->images[engraving->art_subid], netEngraving->mutable_image()); if (chunk->images[engraving->art_subid]) {
CopyImage(chunk->images[engraving->art_subid], netEngraving->mutable_image());
}
netEngraving->set_floor(engraving->flags.bits.floor); netEngraving->set_floor(engraving->flags.bits.floor);
netEngraving->set_west(engraving->flags.bits.west); netEngraving->set_west(engraving->flags.bits.west);
netEngraving->set_east(engraving->flags.bits.east); netEngraving->set_east(engraving->flags.bits.east);