startSessionUAC():
Move the session smart pointer into the try statement,
on the same manner as done in `startSessionUAS()`.
Change-Id: I34d9176fd9c740614f822083b4a3f2dcde53b0f8
Make it using spaces, instead of the EMACS based
tabulation/space combination, which makes it
messy for modern IDEs.
Change-Id: I44b632a5a3a5451bee58726370d907e3634ea709
When building up the AmSession and assigning
the app parameters to it, do the move operation
instead of copying.
Fixes defect:
569 // ... and do nothing !
570
571 DBG("onInvite/onRefer returned NULL\n");
572 }
573 else {
574 // save session parameters
>>> CID 550234: Performance inefficiencies (COPY_INSTEAD_OF_MOVE)
>>> "app_params" is copied in call to copy assignment for class
"std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,
std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >,
std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >,
std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > > > >", when it could be moved instead.
575 session->app_params = app_params;
576 }
577
578 return session;
579 }
580
Change-Id: I3502a4c36ab6ef24fe53d57e2d5fb01777232b2b
Instead of copying the FilterEntry mf, do the move.
Fixes defect:
329 vector<string> elems = explode(value, ",");
330 for (vector<string>::iterator it=elems.begin(); it != elems.end(); it++)
331 {
332 mf.filter_list.insert(*it);
333 }
334 mf.filter_type = Undefined;
>>> CID 550235: Performance inefficiencies (COPY_INSTEAD_OF_MOVE)
>>> "mf" is copied and then passed-by-reference as parameter to STL insertion function
"std::vector<FilterEntry, std::allocator<FilterEntry> >::push_back(
std::vector<FilterEntry, std::allocator<FilterEntry> >::value_type const &)",
when it could be moved instead.
335 profile->messagefilter.push_back(mf);
336 DBG("message_list set to '%s'\n", value.c_str());
337 EXEC_ACTION_STOP;
338 }
339
340 }
Change-Id: If6d04432f7004993fb1c70a0a026799805ed2a1a
We are now ready to use the default constructors and assignment
operators. Add move semantics as well.
Change-Id: I89738bff6498979ff9df6bfe1f9489568c4564cf
Directly contain the ValueArray in the variant instead of manually
managing a pointer. Requires updating the return type of some const
functions to also be const, which in turn requires some of their users
to have the type const qualified as well.
Change-Id: I2ec31d659eef521a3f68d642ee431b5c38f27fdf
Update the AmArg argument to const as these functions never change it,
and it may come from a const source. (The `string` counterpart in the
other overload is already const qualified.)
Change-Id: I1e527425a70e0c6468b8b59de7e4a20fa1f5c218
When dereferencing it (after creating a new context before)
make sure it's not NULL even when just checking for
a connection error, as it might still be NULL and hence
will just seg.fault in this case.
Fixes:
Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking this->redis_context suggests
that it may be null, but it has already been dereferenced on all paths leading to the check.
Change-Id: I67f88f1dfccef66751298b1c26e85efba0458c1f
size_t will always be true against `>=` because
it's a typedef for unsigned long.
Makes no sense to check it, just log what it is.
Fixes: Unsigned compared against 0 (NO_EFFECT)
unsigned_compare: This greater-than-or-equal-to-zero comparison
of an unsigned value is always true. reply->len >= 0UL.
Change-Id: I75803cbe0760a1b5c4a0d056af86bc992ea0a110
Add a default case for `handle_redis_reply()`.
Fixes:
Dereference after null check (FORWARD_NULL)
4. var_deref_op: Dereferencing null pointer reply.
Change-Id: I22edbc3cb14f7e8662efe4c607e1502fbb8c56b6
Instead of using the `tmpnam()` which doesn't exclude
race conditions on the system (same filenames created
simultaneously), because it doesn't open/reserve the file,
just use the `mkstemp()` which actually genereates a filename
and creates the file for the process.
Upon creating the file, close the FD, as not needed atm.
This file can be then later opened using `SCPopenAction`
or anything alike.
Current new implementation does not unlink the file from
the filesystem and a user of it has to explicitly do that
later with for example the `sys.unlink()` from this same
library.
Additionally: to be able to have excplicit file path (so dir),
add a second parameter to this function to provide a directory.
Fixes:
warning: the use of `tmpnam' is dangerous, better use `mkstemp'
Change-Id: Ib5e89461b2d2288be77d5f1a899e5293b76ebf90
Fixes:
CID 542433: (#1 of 1): Uninitialized scalar variable (UNINIT)
34. uninit_use_in_call: Using uninitialized value mf.
Field mf.filter_type is uninitialized when calling push_back.
Change-Id: Ia5c2c2ebb08f1632f973ef0d08d4dca0c5b8934b
Don't do an extra job many times checking
what is the `profile_param`, just catch this once.
Hence conditions must be self-excluding.
Change-Id: I6d98a082e50777c995538fd6303eb0fe527b301b
If a channel has been allocated with
`ConferenceJoinChannel()` then remember to transfer
the ownership over it to the DSM sessions's
"garbage collector" which later takes care to
deallocate it.
Fixes:
CID 542153: (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable chan going out of scope leaks the storage it points to.
Change-Id: Icdc2c67cf2a349ec70fd83f1cf6a43ecfcf69547
Instead of copying string parameter, just pass via reference.
Fixes:
Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)
Change-Id: I872cd9631bbadc746aea12e7ae5840670fa16e8f
Fixes:
Variable copied when it could be moved (COPY_INSTEAD_OF_MOVE)
copy_constructor_call: varname is passed-by-value as parameter
to std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> > const &), when it could be moved instead.
Do the move operation also for the rvalue beign assigned,
as it is a locally allocated pair.
Change-Id: Iba8e349f13c4f83bcd10e229fb101e7b26872f0e
For the local usage of AmArg (`AmArg var_struct;`),
in case when when a custom string to array convertor
is used, ensure that the `var_struct` was actually
set to something reasonable (non-Undef).
Change-Id: Ic5208a60a028788d7c61d8b9e731d6c6f982fcb1
If import of the DSM module fails, close previously
allocated handler for dynamic linking.
Fixes:
CID 542305: (#1 of 1): Resource leak (RESOURCE_LEAK)
13. leaked_storage: Variable h_dl going out of scope leaks the storage it points to.
Change-Id: I426188a2d819c320862ad7de64a01e5ad08e3725
Just initialize to NULL before going forward.
Fixes:
CID 542426: (#1 of 1): Uninitialized pointer read (UNINIT)
21. uninit_use_in_call: Using uninitialized value script_config.diags when calling operator =
Change-Id: I4ed97e4fbeb371f04f0496565fa03b7b4a302e02
We still have raw pointers in the variant and so we need to deal with
copying the contained objects ourselves.
Change-Id: I0e5f1b56430ffeda9d34ede30ec87cfd45a61662
This doesn't yet do much in terms of memory management as it still uses
pointers for arrays and structs, but it does move management of strings
and blobs into the variant. Further refactoring will bring the full
benefits.
Add specialised == operator to avoid implicit conversions to temporary
AmArg.
Includes white space cleanups.
Change-Id: I1e4bce6b96c2187294044f9f2a30fa7013912139
Move from debian/rules into actual makefile. This is not Debian-specific
and needs to be set for a successful build.
Also it's not a preprocessor option, it's a C++ option.
Change-Id: I19be56f4e319778def5697b1fdbc77a9988ccb9b
Add missing initialisers and fix order.
In some cases the member was actually unused and could just be removed.
Change-Id: I0f0c927eb8271c35dcfd371f225847f62bea2812
Warned-by: Coverity
We are passing here null pointer (so `this->dlg->getCallid()`)
which isn't good.
Just use a default `WARN()` instead.
Fixes:
*** CID 549008: Null pointer dereferences (FORWARD_NULL)
/apps/sbc/CallLeg.cpp: 193 in CallLeg::CallLeg(const CallLeg*, AmSipDialog *, AmSipSubscription *)()
187
188 // enable OA for the purpose of hold request detection
189 if (dlg) {
190 dlg->setOAEnabled(true);
191 dlg->setOAForceSDP(false);
192 }
>>> CID 549008: Null pointer dereferences (FORWARD_NULL)
>>> Passing null pointer "this->dlg->getCallid()" to "c_str", which dereferences it.
[Note: The source code implementation of the function has been overridden by a builtin model.]
193 else ILOG_DLG(L_WARN, "can't enable OA!\n");
194
195 // code below taken from createCalleeSession
196
197 const AmSipDialog* caller_dlg = caller->dlg;
198
Change-Id: If1f62386c9a2d3f6df4a12a2b157802b8a0677fa
These are all instances of an object being put into a container just
before it goes out of scope. Use move semantics to avoid copying.
Change-Id: I9c40a56c4a67df2b8e244d51f068b50ec286f5bf
Warned-by: Coverity
Use a static cast to make sure we use the right type for
std::string::length()
Change-Id: I3b21146ca8898d7e1f3b35c83389d37eadac5ff6
Warned-by: Coverity
Make it more explicit that this is meant to set the flag instead of
doing a comparison with a typo.
Change-Id: I31a1a7f35b9072f157105f6c2acdd2caf9bea09a
Warned-by: Coverity
Otherwise we can end up with:
Program terminated with signal SIGSEGV, Segmentation fault.
104 ./core/AmSession.cpp: No such file or directory.
[Current thread is 1 (Thread 0x7fc7dd677e40 (LWP 176249))]
Change-Id: Ia61de0caa9b1764839c740e62bc3f463da4ed4dc
Introduce `ILOG_SDLG()` call-id logging based on
specific getter provided to the macro func as a param.
This is required for those implementations,
where there is no within-file common dialog id getter.
Change-Id: I90501a0da32c7b8075e181796cf4c7c3f980e81e
Make the way we get call-id when calling ILOG_DLG()
file specific, which allows to define locally
(within a target file) how to get the call-id value.
Change-Id: I4af87edf9d1ea52d9678b3354bc797cf1f5f0b54
A fix-up for 3745ff0778d6a55.
This must fix:
Program terminated with signal SIGSEGV, Segmentation fault.
"*\302\3242R \204\vg\266f9\356\277[\252\336J\205\371\020Ŵ\313ٛ\v\231\214\360\355\243\034g\022\001\n\025")
at ./core/sip/sip_parser_async.cpp:205
205 ./core/sip/sip_parser_async.cpp: No such file or directory.
[Current thread is 1 (Thread 0x7f80c07ea6c0 (LWP 3928994))]
(gdb) bt full
"*\302\3242R \204\vg\266f9\356\277[\252\336J\205\371\020Ŵ\313ٛ\v\231\214\360\355\243\034g\022\001\n\025")
at ./core/sip/sip_parser_async.cpp:205
err = 0
c = @0x7f807c001390: 0x7f807c00140e "*\302\3242R \204\vg\266f9\356\277[\252\336J\205\371\020Ŵ\313ٛ\v\231\214\360\355\243\034g\022\001\n\025"
st = @0x7f807c0013a4: 102
saved_st = @0x7f807c0013a8: 0
hdr = 0x0
Change-Id: Icde152783b9dc5a68dde9d29f96d1d87b36e0671
In some cases it can happen that ::join() is called from multiple
threads at the same time. Checking the ::joinable() flag is not
race-free and so is unreliable to make sure that only one other thread
attempts to join at any given time. Add a mutex and a state variable to
make sure only one thread attempts to join, and make any other threads
wait.
Change-Id: I02fd236a416b035c98642535f1521be4a3a63fd9