mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fixed potential NULL pointer and leak when setting node metadata
This commit is contained in:
parent
747bc40840
commit
5be786c804
5 changed files with 56 additions and 19 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue