summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter Harms <wharms@bfs.de>2019-12-22 18:48:02 +0100
committerWalter Harms <wharms@bfs.de>2019-12-22 18:48:02 +0100
commit15a6234f9bee37d3c25bb21ce66db5846e082563 (patch)
tree41f62ed13e16f907594b1363911f930a6da26fbd
parent6cc7763e4bb7298a6c81f81015d6e750d6b4ea5c (diff)
add errorhandling to _XtVaToTypedArgList()
to make it behave like _XtVaToTypedArgList() add some checks and make sure that all args are propper initialized. also replace Malloc with Calloc and get arg check for free Signed-off-by: Walter Harms <wharms@bfs.de>
-rw-r--r--src/Varargs.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Varargs.c b/src/Varargs.c
index 4e1f647..cde629a 100644
--- a/src/Varargs.c
+++ b/src/Varargs.c
@@ -356,11 +356,10 @@ _XtVaToArgList(Widget widget,
if (max_count == 0)
return;
- args = (ArgList)__XtMalloc((Cardinal)((size_t)(max_count * 2) * sizeof(Arg)));
+ args = (ArgList)__XtCalloc((size_t)(max_count * 2), sizeof(Arg));
if (!args)
return;
- for (count = max_count * 2; --count >= 0; )
- args[count].value = (XtArgVal) NULL;
+
count = 0;
for(attr = va_arg(var, String) ; attr != NULL;
@@ -482,14 +481,24 @@ _XtVaToTypedArgList(va_list var,
XtTypedArgList *args_return,
Cardinal *num_args_return)
{
- XtTypedArgList args = NULL;
+ XtTypedArgList args;
String attr;
int count;
+ *args_return = NULL;
+ *num_args_return = 0;
+
+ if (max_count == 0)
+ return;
+
args = (XtTypedArgList)
- __XtMalloc((Cardinal) ((size_t) max_count * sizeof(XtTypedArg)));
+ __XtCalloc((size_t) max_count , sizeof(XtTypedArg));
+ if (!args)
+ return;
- for (attr = va_arg(var, String), count = 0; attr != NULL;
+ count=0;
+
+ for (attr = va_arg(var, String); attr != NULL;
attr = va_arg(var, String)) {
if (strcmp(attr, XtVaTypedArg) == 0) {
args[count].name = va_arg(var, String);