Просмотр исходного кода

(error) va_list 'args' was opened but not closed by va_end()

The manpage of va_start and co additionally says:
On some systems, va_end contains a closing '}' matching a '{' in
va_start, so that both macros must occur in the same function, and in a
way that allows this.

So instead of return/breaking instantly, we save the return, make a
proper turndown with va_end in all cases and only end after that.

Reported-By: cppcheck
Git-Dch: Ignore
David Kalnischkies лет назад: 11
Родитель
Сommit
ce105e8740
1 измененных файлов с 8 добавлено и 4 удалено
  1. 8 4
      apt-pkg/contrib/strutl.cc

+ 8 - 4
apt-pkg/contrib/strutl.cc

@@ -1319,10 +1319,12 @@ void ioprintf(ostream &out,const char *format,...)
    va_list args;
    ssize_t size = 400;
    while (true) {
+      bool ret = false;
       va_start(args,format);
-      if (iovprintf(out, format, args, size) == true)
-	 return;
+      ret = iovprintf(out, format, args, size);
       va_end(args);
+      if (ret == true)
+	 return;
    }
 }
 void strprintf(string &out,const char *format,...)
@@ -1331,10 +1333,12 @@ void strprintf(string &out,const char *format,...)
    ssize_t size = 400;
    std::ostringstream outstr;
    while (true) {
+      bool ret = false;
       va_start(args,format);
-      if (iovprintf(outstr, format, args, size) == true)
-	 break;
+      ret = iovprintf(outstr, format, args, size);
       va_end(args);
+      if (ret == true)
+	 break;
    }
    out = outstr.str();
 }