Fix crash on failure to create service

The service would not be in the list if it failed before it was placed
there. Moving the actual freeing of memory into the Service destructor
allows it to be called directly when we know the service is not in the
list. This also only allows valid services to be placed into the global
list of services.

To prevent freeing a partially constructed service, the memory allocation
checks were replaced with a runtime assertion. This can be changed when
the creation of the service is done only at a point where we know it can't
fail. Currently, the createInstance call expects the service as a
parameter which prevents this.
This commit is contained in:
Markus Mäkelä
2018-08-02 08:53:05 +03:00
parent d412b8d729
commit be6a404c0b
2 changed files with 34 additions and 36 deletions

View File

@ -26,8 +26,10 @@
*/
// The internal service representation. Currently it only inherits the SERVICE struct.
struct Service: public SERVICE
class Service: public SERVICE
{
public:
~Service();
};
/**