瀏覽代碼

fix create netbuf_new in udp_netsettings

balbekova 7 年之前
父節點
當前提交
13627c61a2
共有 1 個文件被更改,包括 7 次插入5 次删除
  1. 7 5
      modules/Ethernet/udp_netsetting.c

+ 7 - 5
modules/Ethernet/udp_netsetting.c

@@ -294,11 +294,13 @@ void udp_netsettings_task(void *arg)
 
         if (len > 0) {
             buf_snd = netbuf_new();
-            data_snd = netbuf_alloc(buf_snd,len);
-            memcpy(data_snd, dataBuf1, len);
-            netconn_send(udp_conn, buf_snd);
-            netbuf_delete(buf_snd);
-            DBG printf("\r\nSent (%u bytes): \t%s\r\n", (unsigned int)len, dataBuf1);
+            if(buf_snd != NULL){
+				data_snd = netbuf_alloc(buf_snd,len);
+				memcpy(data_snd, dataBuf1, len);
+				netconn_send(udp_conn, buf_snd);
+				netbuf_delete(buf_snd);
+				DBG printf("\r\nSent (%u bytes): \t%s\r\n", (unsigned int)len, dataBuf1);
+            }
         }
 
 		netconn_disconnect(udp_conn);