[6/8] widl: Null-check pointers with [size_is]

Michael Karcher wine at mkarcher.dialup.fu-berlin.de
Sat Jan 10 15:38:46 CST 2009


This matches midl behaviour. In

  void test1([out,size_is(x)] char str[], [in] int x);
  void test2([size_is(x), out] char* str, [in] int x);

the parameter to test1 is not NULL-checked, but the one to test2 is.
---
 tools/widl/client.c    |    2 +-
 tools/widl/proxy.c     |   15 ++++++++++-----
 tools/widl/widltypes.h |    1 +
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/widl/client.c b/tools/widl/client.c
index a23e298..0b10eb6 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -59,7 +59,7 @@ static void check_pointers(const var_t *func)
 
     LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
     {
-        if (is_var_ptr(var) && cant_be_null(var))
+        if (is_var_declptr(var) && cant_be_null(var))
         {
             print_client("if (!%s)\n", var->name);
             print_client("{\n");
diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c
index bb16b72..ce07ddc 100644
--- a/tools/widl/proxy.c
+++ b/tools/widl/proxy.c
@@ -150,6 +150,11 @@ int is_var_ptr(const var_t *v)
   return is_ptr(v->type);
 }
 
+int is_var_declptr(const var_t *v)
+{
+  return is_declptr(v->type);
+}
+
 int cant_be_null(const var_t *v)
 {
   /* Search backwards for the most recent pointer attribute.  */
@@ -164,10 +169,10 @@ int cant_be_null(const var_t *v)
   if (is_user_type(type))
       return 0;
 
-  if (!attrs && is_ptr(type))
+  if (!attrs && is_declptr(type))
   {
     attrs = type->attrs;
-    type = type_pointer_get_ref(type);
+    type = get_deref_type(type);
   }
 
   while (attrs)
@@ -180,7 +185,7 @@ int cant_be_null(const var_t *v)
     if (t == RPC_FC_RP)
       return 1;
 
-    if (is_ptr(type))
+    if (is_declptr(type))
     {
       if (type->type == RPC_FC_FP ||
           type->type == RPC_FC_OP ||
@@ -188,7 +193,7 @@ int cant_be_null(const var_t *v)
         return 0;
 
       attrs = type->attrs;
-      type = type_pointer_get_ref(type);
+      type = get_deref_type(type);
     }
     else
       attrs = NULL;
@@ -229,7 +234,7 @@ static void proxy_check_pointers( const var_list_t *args )
   if (!args) return;
   LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
   {
-    if (is_var_ptr(arg) && cant_be_null(arg)) {
+    if (is_var_declptr(arg) && cant_be_null(arg)) {
         print_proxy( "if(!%s)\n", arg->name );
         indent++;
         print_proxy( "RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index fe8c250..6a770c3 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -445,6 +445,7 @@ void clear_all_offsets(void);
 int is_ptr(const type_t *t);
 int is_array(const type_t *t);
 int is_var_ptr(const var_t *v);
+int is_var_declptr(const var_t *v);
 int cant_be_null(const var_t *v);
 int is_struct(unsigned char tc);
 int is_union(unsigned char tc);
-- 
1.5.6.5





More information about the wine-devel mailing list