Przeglądaj źródła

Update rws_frame.c (#4)

* Update rws_frame.c

原始代码中存在动态申请指针地址修改。
在触发该代码运行时,调用释放指针的时候,必然出错。
需要修复。

* Update rws_frame.c

Co-authored-by: Man, Jianting (Meco) <920369182@qq.com>
shouchengcheng 3 lat temu
rodzic
commit
b6ceff72f1
1 zmienionych plików z 3 dodań i 2 usunięć
  1. 3 2
      librws/src/rws_frame.c

+ 3 - 2
librws/src/rws_frame.c

@@ -289,16 +289,17 @@ void rws_frame_fill_with_send_bin(_rws_frame *f, const void *data, const size_t
 void rws_frame_combine_datas(_rws_frame *to, _rws_frame *from)
 {
     unsigned char *comb_data = (unsigned char *)rws_malloc(to->data_size + from->data_size);
+    int offset = 0;
     if (comb_data)
     {
         if (to->data && to->data_size)
         {
             memcpy(comb_data, to->data, to->data_size);
         }
-        comb_data += to->data_size;
+        offset += to->data_size;
         if (from->data && from->data_size)
         {
-            memcpy(comb_data, from->data, from->data_size);
+            memcpy(comb_data + offset, from->data, from->data_size);
         }
     }
     rws_free(to->data);