X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/5039a4c529d8c62bfd770fe90347a7805f31724a..107d054ba954d05965f793f560468c6c453cc2a5:/apt-pkg/contrib/error.cc?ds=sidebyside

diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index fe50e606b..892cd4874 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -13,19 +13,22 @@
    ##################################################################### */
 									/*}}}*/
 // Include Files							/*{{{*/
+#include <config.h>
+
 #include <apt-pkg/error.h>
 
+#include <stdarg.h>
+#include <stddef.h>
+#include <list>
 #include <iostream>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-
 #include <string>
 #include <cstring>
 
-#include "config.h"
-   									/*}}}*/
+									/*}}}*/
 
 // Global Error Object							/*{{{*/
 /* If the implementation supports posix threads then the accessor function
@@ -66,9 +69,10 @@ bool GlobalError::NAME (const char *Function, const char *Description,...) { \
 	int const errsv = errno; \
 	while (true) { \
 		va_start(args,Description); \
-		if (InsertErrno(TYPE, Function, Description, args, errsv, msgSize) == false) \
-			break; \
+		bool const retry = InsertErrno(TYPE, Function, Description, args, errsv, msgSize); \
 		va_end(args); \
+		if (retry == false) \
+			break; \
 	} \
 	return false; \
 }
@@ -87,9 +91,10 @@ bool GlobalError::InsertErrno(MsgType const &type, const char *Function,
 	int const errsv = errno;
 	while (true) {
 		va_start(args,Description);
-		if (InsertErrno(type, Function, Description, args, errsv, msgSize) == false)
-			break;
+		bool const retry = InsertErrno(type, Function, Description, args, errsv, msgSize);
 		va_end(args);
+		if (retry == false)
+		   break;
 	}
 	return false;
 }
@@ -107,6 +112,7 @@ bool GlobalError::InsertErrno(MsgType type, const char* Function,
 			msgSize = n + 1;
 		else
 			msgSize *= 2;
+		free(S);
 		return true;
 	}
 
@@ -160,6 +166,7 @@ bool GlobalError::Insert(MsgType type, const char* Description,
 			msgSize = n + 1;
 		else
 			msgSize *= 2;
+ 		free(S);
 		return true;
 	}
 
@@ -191,7 +198,7 @@ bool GlobalError::PopMessage(std::string &Text) {
 
 	// check if another error message is pending
 	for (std::list<Item>::const_iterator m = Messages.begin();
-	     m != Messages.end(); m++)
+	     m != Messages.end(); ++m)
 		if (m->Type == ERROR || m->Type == FATAL)
 			return Ret;
 
@@ -208,7 +215,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
 			Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end());
 
 	for (std::list<Item>::const_iterator m = Messages.begin();
-	     m != Messages.end(); m++)
+	     m != Messages.end(); ++m)
 		if (m->Type >= threshold)
 			out << (*m) << std::endl;
 	Discard();
@@ -218,7 +225,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold,
 void GlobalError::Discard() {
 	Messages.clear();
 	PendingFlag = false;
-};
+}
 									/*}}}*/
 // GlobalError::empty - does our error list include anything?		/*{{{*/
 bool GlobalError::empty(MsgType const &trashhold) const {
@@ -229,7 +236,7 @@ bool GlobalError::empty(MsgType const &trashhold) const {
 		return true;
 
 	for (std::list<Item>::const_iterator m = Messages.begin();
-	     m != Messages.end(); m++)
+	     m != Messages.end(); ++m)
 		if (m->Type >= trashhold)
 			return false;