tools/widl/typegen.c pointer initialization

Gerald Pfeifer gerald at pfeifer.com
Sun Oct 28 07:51:34 CDT 2007


In tools/widl/typegen.c we have the following snippet

  static void write_user_tfs(FILE *file, type_t *type, unsigned int *tafsoff)
  {
    unsigned int start, absoff, flags;
    unsigned int align = 0, ualign = 0;
    const char *name;
    type_t *utype = get_user_type(type, &name);

which passes name to get_user_type without initializing it.  get_user_type
in return has the following piece of code:

  static type_t *get_user_type(const type_t *t, const char **pname)
  {
    for (;;)
    {
        type_t *ut = get_attrp(t->attrs, ATTR_WIREMARSHAL);
        if (ut)
        {
            if (pname)
                *pname = t->name;
            return ut;
        }

It is unclear to this reader (and various versions of GCC I tested),
whether we don't really use *name (*pname) uninitialized here.  Now
it is possible that through some of the, hmm, tricky logic in these
two functions combined with some environmental guarantees it happens
that we don't, but it seems better to be proactive here.

Gerald

ChangeLog:
Initialize pointers in write_user_tfs() and get_required_buffer_size_type().

Index: tools/widl/typegen.c
===================================================================
RCS file: /home/wine/wine/tools/widl/typegen.c,v
retrieving revision 1.194
diff -u -3 -p -r1.194 typegen.c
--- tools/widl/typegen.c	25 Oct 2007 13:40:28 -0000	1.194
+++ tools/widl/typegen.c	28 Oct 2007 12:48:38 -0000
@@ -950,7 +950,7 @@ static void write_user_tfs(FILE *file, t
 {
     unsigned int start, absoff, flags;
     unsigned int align = 0, ualign = 0;
-    const char *name;
+    const char *name = 0;
     type_t *utype = get_user_type(type, &name);
     size_t usize = user_type_has_variable_size(utype) ? 0 : type_memsize(utype, &ualign);
     size_t size = type_memsize(type, &align);
@@ -2285,7 +2285,7 @@ static unsigned int get_required_buffer_
     *alignment = 0;
     if (is_user_type(type))
     {
-        const char *uname;
+        const char *uname = 0;
         const type_t *utype = get_user_type(type, &uname);
         return get_required_buffer_size_type(utype, uname, alignment);
     }



More information about the wine-patches mailing list