Browse Source

TT#14008 add log_info_pop_until()

To safeguard against non-refcounted objects being left over in a log
info piece (e.g. a string on the stack), add this new function to pop
pieces from the stack until the desired one is removed. This is needed
in case of a unpaired log_info_* without a matching log_info_pop.

closes #1511

Change-Id: I689de14d034df779521dfdf59f923fdbf7fabc9b
pull/1525/head
Richard Fuchs 3 years ago
parent
commit
59a16e747b
3 changed files with 13 additions and 1 deletions
  1. +1
    -1
      daemon/control_ng.c
  2. +10
    -0
      daemon/log_funcs.h
  3. +2
    -0
      t/log_funcs.h

+ 1
- 1
daemon/control_ng.c View File

@ -399,7 +399,7 @@ send_only:
out:
ng_buffer_release(ngbuf);
release_closed_sockets();
log_info_pop();
log_info_pop_until(&callid);
return funcret;
}


+ 10
- 0
daemon/log_funcs.h View File

@ -47,6 +47,16 @@ INLINE void log_info_pop(void) {
g_slice_free1(sizeof(*next), next);
log_info_stack = g_slist_delete_link(log_info_stack, log_info_stack);
}
// should be used with non-refcounted log info pieces
INLINE void log_info_pop_until(void *p) {
assert(p != NULL);
while (log_info.u.ptr) {
void *prev = log_info.u.ptr;
log_info_pop();
if (prev == p)
break;
}
}
// clears current log context and entire stack
INLINE void log_info_reset(void) {
__log_info_release(&log_info);


+ 2
- 0
t/log_funcs.h View File

@ -12,6 +12,8 @@ INLINE void log_info_reset(void) {
}
INLINE void log_info_pop(void) {
}
INLINE void log_info_pop_until(void *p) {
}
INLINE void log_info_call(struct call *c) {
}
INLINE void log_info_stream_fd(struct stream_fd *sfd) {


Loading…
Cancel
Save