Internally the parsing still happens on pointers, but the externally
visible function will be using string_view eventually, when all other
users are converted.
Change-Id: I87d3be9e41fd96f656ce242edc1c403425f3eb65
Automatic memory management and less error prone as it avoids manual
pointer manipulations.
No functional change.
Change-Id: Id35f4e4dc8918436589001db4acdf55ff9c60e5f
Use references instead of pointers.
Use object operators instead of memcpy and memset.
Remove redundant ctors.
Change-Id: I04440450070af17909efbd957f42a3c561e658ab
Instead of copying, move that.
And then later for the local socket assignment
operations use a copy connections map member used
as a destination shortly before.
Closes Coverity CID 642750.
Change-Id: Ief7891c1962251b33cd5960e74e4081685881dcf
To determine whether a timer has been added to a list yet, use a
dedicated link object wrapped in an "optional" (empty state meaning not
added to a list), instead of a raw pointer and its NULL state.
Change-Id: I70ca342d8c9e4900140529977c99b3b0f61a5588
Requesting removal of a timer that isn't present in the list indicates a
race condition. Something else has already removed/disarmed the timer
(possibly from firing the timer), and that something else is then in
charge of freeing the object. Therefore do not free the timer object at
removal if the timer wasn't armed.
Change-Id: I26b58b6dc3400acf3241375da3cde879a5968d41
Use shared_ptr for automatic reference counting of sockets, instead of
doing it manually through atomic_ref_cnt.
Use shared_ptr instead of raw pointers in all appropriate places.
Add const qualifier for a few methods.
No functional change.
Change-Id: I7db07fd90a2398f0253290aa2d810f8599e3983e
Reverse inheritence between singleton class and its base.
Change singleton template so that the singleton class doesn't inherit
from its base, but rather that the singelton class inherits from the
singleton template. This removes the need to keep the singleton base
classes separate (with the underscore prefix) plus a `typedef` for the
singleton class, and instead makes the class itself become the
singleton. (The exception being intermediate classes that have multiple
other derived classes, which is only the wheeltimer).
This makes for cleaner typing, but requires use of listing the singleton
template as friend class.
No functional changes.
Change-Id: Ic45cb01f7870ce0ba97188e58340b10fdc0380cb
Use a container for the actual objects instead of manually managing
pointers. Switch from vector to deque as AmThread isn't
copy-constructible.
No functional changes.
Change-Id: I1bbcdcd961319b78612c6fa64dd95fdda8e43d2c
Eliminate the need to specify the "less than" operator explicitly as
part of the template arguments by specialising std::less, which is the
default operator.
Change-Id: I435792a5b9bd1783275c9632dc7c917e47d2e2f1
This was probably intended as a helper to facilitate reference counted
pointers, but this isn't used anywhere, and the only "allocator" in use
is the default wrapper around `delete`. If reference counted pointers
are ever relevant, they can be done using a shared_ptr.
Change-Id: I2adb561b76efcaf5fb119939f25a7c2438196a5b
Refactor it so, that it's not possible to go over what
`unsigned long` offers (so 4,294,967,295).
We are accumulating read bytes there, which can potentially
be more than proposed 4,3Gb, for that case check out if
the possible end result will overflow and close connection
if this is likely to happen.
Change-Id: I4e758292e77649ddfbcaaa7f8dc9f133e74c4600
The memory referenced via it could have been freed already
(by the `update_uac_request()`). Set the original pointer to NULL
and check in the caller's function if it has been assigned to NULL
before actually using.
Fixes:
Read from pointer after free (USE_AFTER_FREE)
41. deref_after_free: Dereferencing freed pointer p_msg.
Change-Id: I07ee9360f996c8723ba46c99f512ef9562ff75c3
To be able to set msg's ptr to NULL in the `update_uac_request()`
after the memory referenced via it is freed.
Change-Id: Id8d89a6a64b78e5fd06d43e0b99aaf83c4623908
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
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
On shutdown, call shutdown() in the socket, so that a thread blocked in
recv() wakes up and gets a chance to exit cleanly.
Change-Id: I24b1b7c608ec1307019b424becef31e8db02e7bb
Zero is a valid file descriptor. Anything that's not -1 can in fact be a
valid file descriptor.
Make sure `sd` is set to -1 whenever no socket is open.
Add dtor to socket class to close the socket if it's open.
Add a few related formatting fixes as well.
Change-Id: Id9d3ad74b986c82ac6ab698a1e8f1f38e0f92414