We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb808f3 commit 6394797Copy full SHA for 6394797
components/drivers/serial/serial_tty.c
@@ -62,7 +62,11 @@ static char *alloc_device_name(struct rt_serial_device *serial)
62
* must be obtained using the serial_dev_set_name function,
63
* and it should begin with "uart".
64
*/
65
- RT_ASSERT((strlen(serial_name) > strlen("uart")) && (strncmp(serial_name, "uart", 4) == 0));
+ if (!serial_name || rt_strlen(serial_name) < 4 || rt_strncmp(serial_name, "uart", 4))
66
+ {
67
+ return RT_NULL;
68
+ }
69
+
70
long digits_len = (sizeof(TTY_NAME_PREFIX) - 1) /* raw prefix */
71
+ strlen(serial_name + sizeof("uart") - 1) /* suffix of serial device name*/
72
+ 1; /* tailing \0 */
0 commit comments