]> git.decadent.org.uk Git - videolink.git/blobdiff - null_prompt_service.cpp
Fixed initial reference count for null_prompt_service instances so that fatal error...
[videolink.git] / null_prompt_service.cpp
index 878f7ff268f71057127e1f997287ad0b024d0077..37303c054a089211e373c4158d5de66f7af8b439 100644 (file)
@@ -1,6 +1,7 @@
 // Copyright 2006 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
+#include <new>
 #include <string>
 
 #include <langinfo.h>
@@ -36,12 +37,14 @@ namespace
        if (!iid.Equals(prompt_service_iid))
            return NS_ERROR_NO_INTERFACE;
 
-       try
+       if (null_prompt_service * service =
+               new (std::nothrow) null_prompt_service)
        {
-           *result = new null_prompt_service;
+           service->AddRef();
+           *result = service;
            return NS_OK;
        }
-       catch (std::bad_alloc &)
+       else
        {
            return NS_ERROR_OUT_OF_MEMORY;
        }