Browse Source

fix create netbuf_new in udp_netsettings

balbekova 7 years ago
parent
commit
13627c61a2
1 changed files with 7 additions and 5 deletions
  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);