Merge lp:~vkolesnikov/pbxt/pbxt-vasprintf into lp:pbxt

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: 850
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-vasprintf
Merge into: lp:pbxt
Diff against target: 29 lines (+8/-3)
1 file modified
src/thread_xt.cc (+8/-3)
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-vasprintf
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+34423@code.launchpad.net

Description of the change

merged into the latest lp:pbxt

To post a comment you must log in.
Revision history for this message
Paul McCullagh (paul-mccullagh) wrote :

Hi Vlad,

I am not so sure about this now. The code no longer uses ap2. But, I think it may be required, as was done previously. I think the first call to vsnprintf() clobbers ap.

It would be good to run this code once to check that it works.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/thread_xt.cc'
--- src/thread_xt.cc 2010-05-06 12:37:19 +0000
+++ src/thread_xt.cc 2010-09-02 14:26:09 +0000
@@ -203,7 +203,8 @@
203{203{
204 char buffer[DEFAULT_LOG_BUFFER_SIZE];204 char buffer[DEFAULT_LOG_BUFFER_SIZE];
205 char *log_string = NULL;205 char *log_string = NULL;
206206 int bufsize;
207
207 if (level > log_level)208 if (level > log_level)
208 return;209 return;
209210
@@ -226,9 +227,13 @@
226 va_list ap2;227 va_list ap2;
227228
228 va_copy(ap2, ap);229 va_copy(ap2, ap);
229 if (vsnprintf(buffer, DEFAULT_LOG_BUFFER_SIZE, fmt, ap) >= DEFAULT_LOG_BUFFER_SIZE) {230 bufsize = vsnprintf(buffer, DEFAULT_LOG_BUFFER_SIZE, fmt, ap);
230 if (vasprintf(&log_string, fmt, ap2) == -1)231 if (bufsize >= DEFAULT_LOG_BUFFER_SIZE) {
232 log_string = (char *)malloc(bufsize + 1);
233 if (vsnprintf(log_string, bufsize + 1, fmt, ap) > bufsize) {
234 free(log_string);
231 log_string = NULL;235 log_string = NULL;
236 }
232 }237 }
233 else238 else
234 log_string = buffer;239 log_string = buffer;

Subscribers

People subscribed via source and target branches