diff options
author | qiankun.miao <qiankun.miao@intel.com> | 2014-07-15 19:51:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-07-15 19:51:41 -0700 |
commit | cd27a41ddafe819fbc597110a50ec9cfadc28c1f (patch) | |
tree | e6219680d070b1e5c72a32625156227c680cfa51 /src/ports | |
parent | be7e59e3b441949749b014830f2686ee0ceb3a96 (diff) |
Use va_list variable safely
va_list variable will be invalid after the first call. Use va_copy to
initialize the va_list for another call.
BUG=skia:
R=djsollen@google.com, mtklein@google.com
Author: qiankun.miao@intel.com
Review URL: https://codereview.chromium.org/394763004
Diffstat (limited to 'src/ports')
-rw-r--r-- | src/ports/SkDebug_android.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ports/SkDebug_android.cpp b/src/ports/SkDebug_android.cpp index 70029fbb6d..b41abd3091 100644 --- a/src/ports/SkDebug_android.cpp +++ b/src/ports/SkDebug_android.cpp @@ -22,15 +22,17 @@ extern "C" void AndroidSkDebugToStdOut(bool debugToStdOut) { } void SkDebugf(const char format[], ...) { - va_list args; - va_start(args, format); - __android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG, format, args); + va_list args1, args2; + va_start(args1, format); + va_copy(args2, args1); + __android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG, format, args1); // Print debug output to stdout as well. This is useful for command // line applications (e.g. skia_launcher) if (gSkDebugToStdOut) { - vprintf(format, args); + vprintf(format, args2); } - va_end(args); + va_end(args1); + va_end(args2); } |