auth_db: auth_check() to get the auth header from the used api

- this avoids using a different auth header that might be in the request
  before checking usernames in from/to headers against auth user

(cherry picked from commit 4992519eed88d94847d742c52e882082b1b41264)
db_mysql: proper handling of mysql_next_result(...) return code

- it indicates the presence of another result if return is 0
- reported by  Maxim (simax), FS#434

(cherry picked from commit 37f0964278e925d5530563b38c82a57de1f7fa59)
rls: Fix memory leak with duplicate entries in lists

- When duplicate detection is requested, free the string and container
- When duplicate detection is not requested, insert the duplicate anyway
parser/sdp: assign stream var only if session is not null

(cherry picked from commit 1cefc0c5f83eb4b7b6ffefc6ab383d7aae6de07f)
pv: safety check for PAI header parsed structure

- reported by Igor Potjevlesch

(cherry picked from commit e633ca6b7e748a77825d3208e86bf9bce18944a5)
dialog: add wait-for-ack callback before response unref

- in case of a sipral for ending in a negative response from initial
  state, ack to second iteration can unref prematurely the dialog
- reported by Pawel Sternal, FS#427

(cherry picked from commit d81fd1bf067b78b55ad348db2531c4ba9b10dddb)
srdb1: fix memory leak in db-id

- When getting an existing connection from the pool, free the newly
  created db-id as the pool connection already has a reference to the
  existing one.  Fixes FS#436
(cherry picked from commit 69de17d3bb1d032f9a41752362194d718336e20d)
auth: enhanced log message when method param fails to be retrieved

(cherry picked from commit 35329870fe22115fd24a396b743e4814278ce46a)
cnxcc: fixed deadlock when call gets terminated under certain conditions

- fixed some indentation problems introduced by Eclipse IDE

(cherry picked from commit d0f0ba702bd44524bc9f52e07341db03267b15f7)
mem/f_malloc: check returned pointer for bitmask index

- if null, reset slot and search on bigger chunks slots

(cherry picked from commit 892a24f7256e60e2a0116655e0052c284479b7d2)
mem/f_malloc: free old pointer if allocation in realloc fails

(cherry picked from commit 41a37b570758445d723d4d78b9786f8e6cb5722c)
mem/q_malloc: free old pointer if allocation in realloc fails

(cherry picked from commit 8c2888fcd33bee45cb4654222da619e70ed44ecc)
dialog: if sending BYE fails at timeout, unref dialog

- destroy dialog structures

(cherry picked from commit e39a90e11bfed2b4445c37db1532488aa9e3e725)
pv: proper length for line transformation when handling last line of value

(cherry picked from commit f1a09e44268c77641216a78878f2c73c6e5a4d66)
core: free previous allocated variable if no more pkg to build rve struct

- cleaner shut down if not enough memory at startup

(cherry picked from commit ace56c6bd2221920b965185c1c9a5997cd3f2768)
db_flatstore: free result before returning null on no more pkg

- partial allocation when doing an incomplete new connection

(cherry picked from commit 74743d6ef3bf74c1226ba5a1b6bebfbe19b06b93)
ipops: free dns pv structure on invalid pv name

(cherry picked from commit e53c715c74fb5b58f4f68b81acb60de66b19b8cc)
rls: proper header define guard and check of null returned value

(cherry picked from commit 4f2da3e025fa281f88e80bb841a51d6546219ae8)
kamcmd: proper size for memset, based on malloc

(cherry picked from commit 7134959725011baa504a027c4561e0054dd907ae)
topoh: match on all ports if none is in the uri for checking self

- forcing default 5060 can fail for multi-listen case and tls

(cherry picked from commit 1d90f4de94dfc887cc6129624fd5e6ad989abd37)