FS-5240: --resolve Please test

This commit is contained in:
William King 2013-05-02 23:57:43 -05:00
parent 784d5722fa
commit 17781cba1c
3 changed files with 40 additions and 23 deletions

View File

@ -201,17 +201,22 @@ static amf0_data * amf0_boolean_read(read_proc_t read_proc, void * user_data) {
/* read a string */
static amf0_data * amf0_string_read(read_proc_t read_proc, void * user_data) {
uint16_t strsize;
uint8_t * buffer;
uint16_t strsize;
uint8_t * buffer = NULL;
amf0_data *data = NULL;
if (read_proc(&strsize, sizeof(uint16_t), user_data) == sizeof(uint16_t)) {
strsize = swap_uint16(strsize);
if (strsize > 0) {
buffer = (uint8_t*)calloc(strsize, sizeof(uint8_t));
if (buffer != NULL && read_proc(buffer, strsize, user_data) == strsize) {
amf0_data * data = amf0_string_new(buffer, strsize);
free(buffer);
return data;
}
buffer = (uint8_t*) calloc(strsize, sizeof(uint8_t));
if ( buffer == NULL ) {
return NULL; // Memory error
}
if ( read_proc(buffer, strsize, user_data) == strsize ) {
data = amf0_string_new(buffer, strsize);
}
free(buffer);
buffer = NULL;
return data;
}
else {
return amf0_string_new(NULL, 0);
@ -634,9 +639,11 @@ void amf0_data_free(amf0_data * data) {
case AMF0_TYPE_NUMBER: break;
case AMF0_TYPE_BOOLEAN: break;
case AMF0_TYPE_STRING:
if (data->u.string_data.mbstr != NULL) {
if (data->u.string_data.mbstr) {
free(data->u.string_data.mbstr);
} break;
data->u.string_data.mbstr = NULL;
}
break;
case AMF0_TYPE_NULL: break;
case AMF0_TYPE_UNDEFINED: break;
/*case AMF0_TYPE_REFERENCE:*/
@ -812,17 +819,19 @@ uint32_t amf0_object_size(amf0_data * data) {
}
amf0_data * amf0_object_add(amf0_data * data, const char * name, amf0_data * element) {
if (data != NULL) {
if (amf0_list_push(&data->u.list_data, amf0_str(name)) != NULL) {
if (amf0_list_push(&data->u.list_data, element) != NULL) {
return element;
}
else {
amf0_data_free(amf0_list_pop(&data->u.list_data));
}
}
if (data != NULL) {
amf0_data *str_name = amf0_str(name);
if (amf0_list_push(&data->u.list_data, str_name) != NULL) {
if (amf0_list_push(&data->u.list_data, element) != NULL) {
return element;
}
else {
amf0_data_free(amf0_list_pop(&data->u.list_data));
}
}
return NULL;
amf0_data_free(str_name);
}
return NULL;
}
amf0_data * amf0_object_get(amf0_data * data, const char * name) {

View File

@ -871,8 +871,6 @@ switch_status_t rtmp_session_destroy(rtmp_session_t **rsession)
switch_thread_rwlock_wrlock((*rsession)->rwlock);
switch_thread_rwlock_unlock((*rsession)->rwlock);
(*rsession)->profile->io->close(*rsession);
#ifdef RTMP_DEBUG_IO
fclose((*rsession)->io_debug_in);
fclose((*rsession)->io_debug_out);

View File

@ -176,8 +176,16 @@ static switch_status_t rtmp_tcp_close(rtmp_session_t *rsession)
switch_mutex_unlock(io->mutex);
switch_socket_close(io_pvt->socket);
io_pvt->socket = NULL;
io_pvt->socket = NULL;
}
if ( io_pvt->sendq ) {
switch_buffer_destroy(&(io_pvt->sendq));
}
free(rsession->io_private);
rsession->io_private = NULL;
return SWITCH_STATUS_SUCCESS;
}
@ -276,6 +284,8 @@ void *SWITCH_THREAD_FUNC rtmp_io_tcp_thread(switch_thread_t *thread, void *obj)
switch_socket_close(io_pvt->socket);
io_pvt->socket = NULL;
io->base.close(rsession);
rtmp_session_destroy(&rsession);
}