Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2013-10-22 12:15:08 +0000
committerEugene Tarassov2013-10-22 12:18:04 +0000
commit93c6d9be59b8bf3c2991485b6c4aecc6fe246f1c (patch)
tree34798ed73d9ed8819e6a9a1aef70d0722db874de /agent/tcf/framework/exceptions.c
parent80322c671d284811654cef18e1b62e584e359273 (diff)
downloadorg.eclipse.tcf.agent-93c6d9be59b8bf3c2991485b6c4aecc6fe246f1c.tar.gz
org.eclipse.tcf.agent-93c6d9be59b8bf3c2991485b6c4aecc6fe246f1c.tar.xz
org.eclipse.tcf.agent-93c6d9be59b8bf3c2991485b6c4aecc6fe246f1c.zip
Bug 419995 - str_fmt_exception does not format the error properly
Diffstat (limited to 'agent/tcf/framework/exceptions.c')
-rw-r--r--agent/tcf/framework/exceptions.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/agent/tcf/framework/exceptions.c b/agent/tcf/framework/exceptions.c
index 2dd3209d..426e82fc 100644
--- a/agent/tcf/framework/exceptions.c
+++ b/agent/tcf/framework/exceptions.c
@@ -81,18 +81,24 @@ void str_exception(int error, const char * msg) {
}
void str_fmt_exception(int error, const char * fmt, ...) {
- va_list vaList;
+ va_list ap;
char * buf = NULL;
size_t len = 100;
int n;
while (1) {
buf = (char *)loc_realloc(buf, len);
- va_start(vaList, fmt);
- n = vsnprintf(buf, len, fmt, vaList);
- va_end(vaList);
- if (n < (int)len) break;
- len = n + 1;
+ va_start(ap, fmt);
+ n = vsnprintf(buf, len, fmt, ap);
+ va_end(ap);
+ if (n < 0) {
+ if (len > 0x1000) break;
+ len *= 2;
+ }
+ else {
+ if (n < (int)len) break;
+ len = n + 1;
+ }
}
error = set_errno(error, buf);
loc_free(buf);

Back to the top