Module: wine Branch: refs/heads/master Commit: 86c3a2e76a76c430dca2f4024700c22538511b6a URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=86c3a2e76a76c430dca2f402...
Author: Robert Shearman rob@codeweavers.com Date: Mon Dec 26 13:08:51 2005 +0100
widl: Fix SEGVs with client and server code generation when an interface has no methods.
---
tools/widl/client.c | 54 ++++++++++++++++++++++------------------ tools/widl/server.c | 52 +++++++++++++++++++++------------------ tools/widl/typegen.c | 67 ++++++++++++++++++++++++++------------------------ 3 files changed, 92 insertions(+), 81 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c index 2d33496..ba73b35 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -403,32 +403,33 @@ static void write_formatdesc( const char
static void write_formatstringsdecl(type_t *iface) { - func_t *func; - var_t *var; int byte_count = 1;
print_client("#define TYPE_FORMAT_STRING_SIZE %d\n", 3); /* FIXME */
/* determine the proc format string size */ - func = iface->funcs; - while (NEXT_LINK(func)) func = NEXT_LINK(func); - while (func) + if (iface->funcs) { - /* argument list size */ - if (func->args) + func_t *func = iface->funcs; + while (NEXT_LINK(func)) func = NEXT_LINK(func); + while (func) { - var = func->args; - while (NEXT_LINK(var)) var = NEXT_LINK(var); - while (var) + /* argument list size */ + if (func->args) { - byte_count += 2; /* FIXME: determine real size */ - var = PREV_LINK(var); + var_t *var = func->args; + while (NEXT_LINK(var)) var = NEXT_LINK(var); + while (var) + { + byte_count += 2; /* FIXME: determine real size */ + var = PREV_LINK(var); + } } + + /* return value size */ + byte_count += 2; /* FIXME: determine real size */ + func = PREV_LINK(func); } - - /* return value size */ - byte_count += 2; /* FIXME: determine real size */ - func = PREV_LINK(func); } print_client("#define PROC_FORMAT_STRING_SIZE %d\n", byte_count);
@@ -492,15 +493,18 @@ void write_client(ifref_t *ifaces) fprintf(client, " */\n"); fprintf(client, "\n");
- write_formatstringsdecl(iface->iface); - write_implicithandledecl(iface->iface); - - write_clientinterfacedecl(iface->iface); - write_stubdescdecl(iface->iface); - write_bindinghandledecl(iface->iface); - - write_function_stubs(iface->iface); - write_stubdescriptor(iface->iface); + if (iface->iface->funcs) + { + write_formatstringsdecl(iface->iface); + write_implicithandledecl(iface->iface); + + write_clientinterfacedecl(iface->iface); + write_stubdescdecl(iface->iface); + write_bindinghandledecl(iface->iface); + + write_function_stubs(iface->iface); + write_stubdescriptor(iface->iface); + }
print_client("#if !defined(__RPC_WIN32__)\n"); print_client("#error Invalid build platform for this stub.\n"); diff --git a/tools/widl/server.c b/tools/widl/server.c index b007a8f..319094c 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -428,32 +428,33 @@ static void write_formatdesc( const char
static void write_formatstringsdecl(type_t *iface) { - func_t *func; - var_t *var; int byte_count = 1;
print_server("#define TYPE_FORMAT_STRING_SIZE %d\n", 3); /* FIXME */
/* determine the proc format string size */ - func = iface->funcs; - while (NEXT_LINK(func)) func = NEXT_LINK(func); - while (func) + if (iface->funcs) { - /* argument list size */ - if (func->args) + func_t *func = iface->funcs; + while (NEXT_LINK(func)) func = NEXT_LINK(func); + while (func) { - var = func->args; - while (NEXT_LINK(var)) var = NEXT_LINK(var); - while (var) + /* argument list size */ + if (func->args) { - byte_count += 2; /* FIXME: determine real size */ - var = PREV_LINK(var); + var_t *var = func->args; + while (NEXT_LINK(var)) var = NEXT_LINK(var); + while (var) + { + byte_count += 2; /* FIXME: determine real size */ + var = PREV_LINK(var); + } } + + /* return value size */ + byte_count += 2; /* FIXME: determine real size */ + func = PREV_LINK(func); } - - /* return value size */ - byte_count += 2; /* FIXME: determine real size */ - func = PREV_LINK(func); } print_server("#define PROC_FORMAT_STRING_SIZE %d\n", byte_count);
@@ -503,14 +504,17 @@ void write_server(ifref_t *ifaces) fprintf(server, " */\n"); fprintf(server, "\n");
- write_formatstringsdecl(iface->iface); - write_serverinterfacedecl(iface->iface); - write_stubdescdecl(iface->iface); - - write_function_stubs(iface->iface); - - write_stubdescriptor(iface->iface); - write_dispatchtable(iface->iface); + if (iface->iface->funcs) + { + write_formatstringsdecl(iface->iface); + write_serverinterfacedecl(iface->iface); + write_stubdescdecl(iface->iface); + + write_function_stubs(iface->iface); + + write_stubdescriptor(iface->iface); + write_dispatchtable(iface->iface); + }
print_server("#if !defined(__RPC_WIN32__)\n"); print_server("#error Invalid build platform for this stub.\n"); diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 09420dc..5f5eb3d 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -119,7 +119,6 @@ static size_t write_procformatstring_var void write_procformatstring(FILE *file, type_t *iface) { int indent = 0; - func_t *func = iface->funcs; var_t *var; unsigned int type_offset = 2;
@@ -130,32 +129,34 @@ void write_procformatstring(FILE *file, print_file(file, indent, "{\n"); indent++;
- while (NEXT_LINK(func)) func = NEXT_LINK(func); - while (func) + if (iface->funcs) { - /* emit argument data */ - if (func->args) + func_t *func = iface->funcs; + while (NEXT_LINK(func)) func = NEXT_LINK(func); + for (; func; func = PREV_LINK(func)) { - var = func->args; - while (NEXT_LINK(var)) var = NEXT_LINK(var); - while (var) + /* emit argument data */ + if (func->args) { - write_procformatstring_var(file, indent, var, FALSE, &type_offset); - var = PREV_LINK(var); + var = func->args; + while (NEXT_LINK(var)) var = NEXT_LINK(var); + while (var) + { + write_procformatstring_var(file, indent, var, FALSE, &type_offset); + var = PREV_LINK(var); + } } + + /* emit return value data */ + var = func->def; + if (is_void(var->type, NULL)) + { + print_file(file, indent, "0x5b, /* FC_END */\n"); + print_file(file, indent, "0x5c, /* FC_PAD */\n"); + } + else + write_procformatstring_var(file, indent, var, TRUE, &type_offset); } - - /* emit return value data */ - var = func->def; - if (is_void(var->type, NULL)) - { - print_file(file, indent, "0x5b, /* FC_END */\n"); - print_file(file, indent, "0x5c, /* FC_PAD */\n"); - } - else - write_procformatstring_var(file, indent, var, TRUE, &type_offset); - - func = PREV_LINK(func); }
print_file(file, indent, "0x0\n"); @@ -214,7 +215,6 @@ static size_t write_typeformatstring_var void write_typeformatstring(FILE *file, type_t *iface) { int indent = 0; - func_t *func = iface->funcs; var_t *var;
print_file(file, indent, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =\n"); @@ -225,20 +225,23 @@ void write_typeformatstring(FILE *file, indent++; print_file(file, indent, "NdrFcShort(0x0),\n");
- while (NEXT_LINK(func)) func = NEXT_LINK(func); - while (func) + if (iface->funcs) { - if (func->args) + func_t *func = iface->funcs; + while (NEXT_LINK(func)) func = NEXT_LINK(func); + for (; func; func = PREV_LINK(func)) { - var = func->args; - while (NEXT_LINK(var)) var = NEXT_LINK(var); - while (var) + if (func->args) { - write_typeformatstring_var(file, indent, var); - var = PREV_LINK(var); + var = func->args; + while (NEXT_LINK(var)) var = NEXT_LINK(var); + while (var) + { + write_typeformatstring_var(file, indent, var); + var = PREV_LINK(var); + } } } - func = PREV_LINK(func); }
print_file(file, indent, "0x0\n");