chiark / gitweb /
copyright dates
[chiark-tcl.git] / base / hook.c
index e0b16d4fac762d7feb2ddb59948f63b89d7917be..0cb2f9d47961615e8dfde1af3966e2198401edcf 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * base code for various Tcl extensions
- * Copyright 2006 Ian Jackson
+ * Copyright 2006-2012 Ian Jackson
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -53,11 +53,15 @@ void cht_obj_updatestr_vstringls(Tcl_Obj *o, ...) {
   va_list al;
   char *p;
   const char *part;
-  int l, pl;
+  int l;
+  size_t pl;
 
   va_start(al,o);
-  for (l=0; (part= va_arg(al, const char*)); )
-    l+= va_arg(al, int);
+  for (l=0; (part= va_arg(al, const char*)); ) {
+    pl= va_arg(al, size_t);
+    assert(pl <= INT_MAX/2 - l);
+    l += pl;
+  }
   va_end(al);
   
   o->length= l;
@@ -65,7 +69,7 @@ void cht_obj_updatestr_vstringls(Tcl_Obj *o, ...) {
 
   va_start(al,o);
   for (p= o->bytes; (part= va_arg(al, const char*)); p += pl) {
-    pl= va_arg(al, int);
+    pl= va_arg(al, size_t);
     memcpy(p, part, pl);
   }
   va_end(al);