Skip to content

Commit 1716ccf

Browse files
committed
change the send_string function, to accept null pointers and send them
as empty strings.
1 parent 92481cc commit 1716ccf

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/proto.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ int spnav_send_str(int fd, int req, const char *str)
1010
int len;
1111
struct reqresp rr = {0};
1212

13-
if(fd == -1 || !str) {
13+
if(fd == -1) {
1414
return -1;
1515
}
1616

17-
len = strlen(str);
17+
len = str ? strlen(str) : 0;
1818
rr.type = req;
1919
rr.data[6] = len;
2020

2121
do {
22-
memcpy(rr.data, str, len > REQSTR_CHUNK_SIZE ? REQSTR_CHUNK_SIZE : len);
22+
if(str) {
23+
memcpy(rr.data, str, len > REQSTR_CHUNK_SIZE ? REQSTR_CHUNK_SIZE : len);
24+
}
2325
write(fd, &rr, sizeof rr);
2426
str += REQSTR_CHUNK_SIZE;
2527
len -= REQSTR_CHUNK_SIZE;

0 commit comments

Comments
 (0)