]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5240: --resolve Please test
authorWilliam King <william.king@quentustech.com>
Fri, 3 May 2013 04:57:43 +0000 (23:57 -0500)
committerWilliam King <william.king@quentustech.com>
Fri, 3 May 2013 05:54:58 +0000 (00:54 -0500)
src/mod/endpoints/mod_rtmp/libamf/src/amf0.c
src/mod/endpoints/mod_rtmp/mod_rtmp.c
src/mod/endpoints/mod_rtmp/rtmp_tcp.c

index 67a9273e2b616c459d7b7b04330895ffffd76111..e62b3098f54973977e56e1d2dd9110ab8d817fed 100644 (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));
-            }
-        }
-    }
-    return NULL;
+  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));
+      }
+    }
+    amf0_data_free(str_name);
+  }
+  return NULL;
 }
 
 amf0_data * amf0_object_get(amf0_data * data, const char * name) {
index 4f865926b0f22cb79d41c894233e95f1e268d94c..9168a902cb26b1def8bbe02175e665cd8fc7fa28 100644 (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);
index 04ab087eb44b7e0ff7562c78a7783092848da3ca..1e5fd118ad5fbd7d449a467ff3ded637c854ce99 100644 (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);
                                }