Commit 9e5f6762 authored by JP Dinger's avatar JP Dinger

Fix an actual error path for realloc() that doesn't leak in rtsp/real.c

parent 30c40ee9
......@@ -18,9 +18,9 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
......@@ -49,6 +49,14 @@ static const unsigned char xor_table[] = {
#define LE_32C(x,y) do {uint32_t in=y; *(uint32_t *)(x)=GetDWLE(&in);} while(0)
#define MAX(x,y) ((x>y) ? x : y)
/* XXX find a better place for this */
static inline void *_realloc(void *p, size_t sz)
{
void *n = realloc(p, sz);
if( !n )
free(p);
return n;
}
static void hash(char *field, char *param)
{
......@@ -689,23 +697,28 @@ rmff_header_t *real_setup_and_get_header(rtsp_client_t *rtsp_session, int bandw
/* setup our streams */
real_calc_response_and_checksum (challenge2, checksum, challenge1);
buf = realloc(buf, strlen(challenge2) + strlen(checksum) + 32);
buf = _realloc(buf, strlen(challenge2) + strlen(checksum) + 32);
if( !buf ) goto error;
sprintf(buf, "RealChallenge2: %s, sd=%s", challenge2, checksum);
rtsp_schedule_field(rtsp_session, buf);
buf = realloc(buf, strlen(session_id) + 32);
buf = _realloc(buf, strlen(session_id) + 32);
if( !buf ) goto error;
sprintf(buf, "If-Match: %s", session_id);
rtsp_schedule_field(rtsp_session, buf);
rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
buf = realloc(buf, strlen(mrl) + 32);
buf = _realloc(buf, strlen(mrl) + 32);
if( !buf ) goto error;
sprintf(buf, "%s/streamid=0", mrl);
rtsp_request_setup(rtsp_session,buf);
if (h->prop->num_streams > 1) {
rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
buf = realloc(buf, strlen(session_id) + 32);
buf = _realloc(buf, strlen(session_id) + 32);
if( !buf ) goto error;
sprintf(buf, "If-Match: %s", session_id);
rtsp_schedule_field(rtsp_session, buf);
buf = realloc(buf, strlen(mrl) + 32);
buf = _realloc(buf, strlen(mrl) + 32);
if( !buf ) goto error;
sprintf(buf, "%s/streamid=1", mrl);
rtsp_request_setup(rtsp_session,buf);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment