Fix crash due to missing pointer validation
authorLoic Blot <loic.blot@unix-experience.fr>
Sun, 2 Jul 2017 20:26:25 +0000 (22:26 +0200)
committerLoic Blot <loic.blot@unix-experience.fr>
Sun, 2 Jul 2017 20:26:25 +0000 (22:26 +0200)
Fix #6092

src/game.cpp

index 827512fbc6be76fb6d83e7ae3c8f2c5e5149a11d..9f7b0ca52c8e92f6ae69668340168d4bb8763e93 100644 (file)
@@ -121,8 +121,7 @@ struct TextDestPlayerInventory : public TextDest
 
 struct LocalFormspecHandler : public TextDest
 {
-       LocalFormspecHandler(const std::string &formname):
-               m_client(NULL)
+       LocalFormspecHandler(const std::string &formname)
        {
                m_formname = formname;
        }
@@ -174,10 +173,11 @@ struct LocalFormspecHandler : public TextDest
                }
 
                // Don't disable this part when modding is disabled, it's used in builtin
-               m_client->getScript()->on_formspec_input(m_formname, fields);
+               if (m_client && m_client->getScript())
+                       m_client->getScript()->on_formspec_input(m_formname, fields);
        }
 
-       Client *m_client;
+       Client *m_client = nullptr;
 };
 
 /* Form update callback */