X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/fa7225c82381bac4432a6edf16f53b5370238d85..refs/heads/master:/OSX/libsecurity_utilities/lib/debugging_internal.cpp diff --git a/OSX/libsecurity_utilities/lib/debugging_internal.cpp b/OSX/libsecurity_utilities/lib/debugging_internal.cpp index d3dcac17..c95c802e 100644 --- a/OSX/libsecurity_utilities/lib/debugging_internal.cpp +++ b/OSX/libsecurity_utilities/lib/debugging_internal.cpp @@ -54,7 +54,7 @@ bool dumping(const char *scope) #if defined(NDEBUG_STUBS) return false; #else - return Target::get().dump(scope); + return Target::get().dumping(scope); #endif } @@ -218,9 +218,11 @@ void Target::message(const char *scope, const char *format, va_list args) // now stuff the message body in, slightly roasted size_t left = buffer + sizeof(buffer) - bufp - 1; // reserve one size_t written = vsnprintf(bufp, left, format, args); - for (char *p = bufp; *p; p++) - if (!isprint(*p)) + for (char *p = bufp; *p; p++) { + if (!isprint(*p)) { *p = '?'; + } + } if (written >= left) { // snprintf overflowed bufp += left; strcpy(bufp - 3, "..."); @@ -255,7 +257,7 @@ void Target::dump(const char *format, va_list args) sink->dump(buffer); } -bool Target::dump(const char *scope) +bool Target::dumping(const char *scope) { return dumpSelector(scope); } @@ -419,6 +421,11 @@ Target &Target::get() if (singleton == NULL) { Target *t = new Target; t->setFromEnvironment(); + + // The Target constructor attempts to set singleton to the object. If it didn't succeed, we don't need T anymore. + if(singleton != t) { + delete t; + } } return *singleton; }