mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 00:25:19 +02:00
Fixed potential NULL pointer and leak when setting node metadata
This commit is contained in:
@@ -340,7 +340,13 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
|
||||
if(n_old.meta != ""){
|
||||
if(!meta){
|
||||
meta = new NodeMetadata(gamedef);
|
||||
map->setNodeMetadata(p, meta);
|
||||
if(!map->setNodeMetadata(p, meta)){
|
||||
delete meta;
|
||||
infostream<<"RollbackAction::applyRevert(): "
|
||||
<<"setNodeMetadata failed at "
|
||||
<<PP(p)<<" for "<<n_old.name<<std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
std::istringstream is(n_old.meta, std::ios::binary);
|
||||
meta->deSerialize(is);
|
||||
|
Reference in New Issue
Block a user