diff options
author | MetaDucky <metaducky AT gmail DOT com> | 2013-11-20 22:11:57 +0100 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2013-11-29 23:35:16 -0500 |
commit | 5be786c804d36e9950598a01cf39f05574af2acc (patch) | |
tree | 488f9fd610b5785389c15d0faa02f840ba9e7110 /src/script/lua_api/l_nodemeta.h | |
parent | 747bc40840ff13bcf9c7a60b790a6de24f94f946 (diff) | |
download | minetest-5be786c804d36e9950598a01cf39f05574af2acc.tar.gz minetest-5be786c804d36e9950598a01cf39f05574af2acc.tar.bz2 minetest-5be786c804d36e9950598a01cf39f05574af2acc.zip |
Fixed potential NULL pointer and leak when setting node metadata
Diffstat (limited to 'src/script/lua_api/l_nodemeta.h')
-rw-r--r-- | src/script/lua_api/l_nodemeta.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/script/lua_api/l_nodemeta.h b/src/script/lua_api/l_nodemeta.h index ed06ff0fa..e39ac3931 100644 --- a/src/script/lua_api/l_nodemeta.h +++ b/src/script/lua_api/l_nodemeta.h @@ -39,6 +39,19 @@ private: static NodeMetaRef *checkobject(lua_State *L, int narg); + /** + * Retrieve metadata for a node. + * If @p auto_create is set and the specified node has no metadata information + * associated with it yet, the method attempts to attach a new metadata object + * to the node and returns a pointer to the metadata when successful. + * + * However, it is NOT guaranteed that the method will return a pointer, + * and @c NULL may be returned in case of an error regardless of @p auto_create. + * + * @param ref specifies the node for which the associated metadata is retrieved. + * @param auto_create when true, try to create metadata information for the node if it has none. + * @return pointer to a @c NodeMetadata object or @c NULL in case of error. + */ static NodeMetadata* getmeta(NodeMetaRef *ref, bool auto_create); static void reportMetadataChange(NodeMetaRef *ref); |