소스 검색

Use strcpy_s under Windows

Stéphane Raimbault 2 년 전
부모
커밋
f807767f9e
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      src/modbus-rtu.c

+ 5 - 0
src/modbus-rtu.c

@@ -1093,7 +1093,12 @@ modbus_new_rtu(const char *device, int baud, char parity, int data_bit, int stop
         errno = ENOMEM;
         return NULL;
     }
+
+#if defined(_WIN32)
+    strcpy_s(ctx_rtu->device, strlen(device) + 1, device);
+#else
     strcpy(ctx_rtu->device, device);
+#endif
 
     ctx_rtu->baud = baud;
     if (parity == 'N' || parity == 'E' || parity == 'O') {