server: Clear last error when creating object without name.
Sebastian Lackner
sebastian at fds-team.de
Sun Nov 1 23:02:16 CST 2015
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
Functions like create_event() only initialize the new object, if the error
is not STATUS_OBJECT_NAME_EXISTS. However, there are some code paths where
the previous error is not cleared.
If multiple objects are created in a row, there is a risk that later objects
are not properly initialized. I'm not aware of a real bug caused by this,
but it probably makes sense to fix it before we run into this issue sooner
or later.
Especially create_event() is a bit critical because its called from various
parts of the wineserver.
server/directory.c | 7 ++++++-
server/named_pipe.c | 7 ++++++-
server/object.c | 6 +++++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/server/directory.c b/server/directory.c
index 4ebc974..3b90f0f 100644
--- a/server/directory.c
+++ b/server/directory.c
@@ -287,7 +287,12 @@ void *create_named_object_dir( struct directory *root, const struct unicode_str
struct object *obj, *new_obj = NULL;
struct unicode_str new_name;
- if (!name || !name->len) return alloc_object( ops );
+ if (!name || !name->len)
+ {
+ if ((new_obj = alloc_object( ops )))
+ clear_error();
+ return new_obj;
+ }
if (!(obj = find_object_dir( root, name, attributes, &new_name ))) return NULL;
if (!new_name.len)
diff --git a/server/named_pipe.c b/server/named_pipe.c
index f5e536c..931dc02 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -671,7 +671,12 @@ static struct named_pipe *create_named_pipe( struct directory *root, const struc
struct named_pipe *pipe = NULL;
struct unicode_str new_name;
- if (!name || !name->len) return alloc_object( &named_pipe_ops );
+ if (!name || !name->len)
+ {
+ if ((pipe = alloc_object( &named_pipe_ops )))
+ clear_error();
+ return pipe;
+ }
if (!(obj = find_object_dir( root, name, attr, &new_name )))
{
diff --git a/server/object.c b/server/object.c
index 965c11c..31883bd 100644
--- a/server/object.c
+++ b/server/object.c
@@ -242,7 +242,11 @@ void *create_named_object( struct namespace *namespace, const struct object_ops
{
struct object *obj;
- if (!name || !name->len) return alloc_object( ops );
+ if (!name || !name->len)
+ {
+ if ((obj = alloc_object( ops ))) clear_error();
+ return obj;
+ }
if ((obj = find_object( namespace, name, attributes )))
{
--
2.6.2
More information about the wine-patches
mailing list