mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-21 01:37:16 +00:00
Bug 948327 - Do not leak the payload object passed to mozilla_sampler_add_marker() if we don't end up using it; r=BenWa
This commit is contained in:
parent
66b63f6557
commit
e276af8c8e
@ -26,8 +26,8 @@ class ProfilerMarkerPayload;
|
||||
inline void* mozilla_sampler_call_enter(const char *aInfo, void *aFrameAddress = nullptr,
|
||||
bool aCopy = false, uint32_t line = 0);
|
||||
inline void mozilla_sampler_call_exit(void* handle);
|
||||
inline void mozilla_sampler_add_marker(const char *aInfo,
|
||||
ProfilerMarkerPayload *aPayload = nullptr);
|
||||
void mozilla_sampler_add_marker(const char *aInfo,
|
||||
ProfilerMarkerPayload *aPayload = nullptr);
|
||||
|
||||
void mozilla_sampler_start(int aEntries, double aInterval,
|
||||
const char** aFeatures, uint32_t aFeatureCount,
|
||||
|
@ -366,27 +366,6 @@ inline void mozilla_sampler_call_exit(void *aHandle)
|
||||
stack->pop();
|
||||
}
|
||||
|
||||
inline void mozilla_sampler_add_marker(const char *aMarker, ProfilerMarkerPayload *aPayload)
|
||||
{
|
||||
if (!stack_key_initialized)
|
||||
return;
|
||||
|
||||
// Don't insert a marker if we're not profiling to avoid
|
||||
// the heap copy (malloc).
|
||||
if (!profiler_is_active()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't add a marker if we don't want to include personal information
|
||||
if (profiler_in_privacy_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PseudoStack *stack = tlsPseudoStack.get();
|
||||
if (!stack) {
|
||||
return;
|
||||
}
|
||||
stack->addMarker(aMarker, aPayload);
|
||||
}
|
||||
void mozilla_sampler_add_marker(const char *aMarker, ProfilerMarkerPayload *aPayload);
|
||||
|
||||
#endif /* ndef TOOLS_SPS_SAMPLER_H_ */
|
||||
|
@ -872,6 +872,33 @@ void mozilla_sampler_tracing(const char* aCategory, const char* aInfo,
|
||||
mozilla_sampler_add_marker(aInfo, new ProfilerMarkerTracing(aCategory, aMetaData));
|
||||
}
|
||||
|
||||
void mozilla_sampler_add_marker(const char *aMarker, ProfilerMarkerPayload *aPayload)
|
||||
{
|
||||
// Note that aPayload may be allocated by the caller, so we need to make sure
|
||||
// that we free it at some point.
|
||||
nsAutoPtr<ProfilerMarkerPayload> payload(aPayload);
|
||||
|
||||
if (!stack_key_initialized)
|
||||
return;
|
||||
|
||||
// Don't insert a marker if we're not profiling to avoid
|
||||
// the heap copy (malloc).
|
||||
if (!profiler_is_active()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't add a marker if we don't want to include personal information
|
||||
if (profiler_in_privacy_mode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PseudoStack *stack = tlsPseudoStack.get();
|
||||
if (!stack) {
|
||||
return;
|
||||
}
|
||||
stack->addMarker(aMarker, payload.forget());
|
||||
}
|
||||
|
||||
// END externally visible functions
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user