Module: kamailio Branch: master Commit: 7ba313f6f96ffa6042c163027c0c7bb65106fef7 URL: https://github.com/kamailio/kamailio/commit/7ba313f6f96ffa6042c163027c0c7bb65106fef7
Author: Daniel-Constantin Mierla <mico...@gmail.com> Committer: Daniel-Constantin Mierla <mico...@gmail.com> Date: 2024-07-24T10:43:18+02:00 jsonrpcc: declare variables are the beginning of function --- Modified: src/modules/jsonrpcc/netstring.c --- Diff: https://github.com/kamailio/kamailio/commit/7ba313f6f96ffa6042c163027c0c7bb65106fef7.diff Patch: https://github.com/kamailio/kamailio/commit/7ba313f6f96ffa6042c163027c0c7bb65106fef7.patch --- diff --git a/src/modules/jsonrpcc/netstring.c b/src/modules/jsonrpcc/netstring.c index be7a5de8108..9328a46215e 100644 --- a/src/modules/jsonrpcc/netstring.c +++ b/src/modules/jsonrpcc/netstring.c @@ -35,11 +35,13 @@ int netstring_read_fd(int fd, char **netstring) { int i, bytes; size_t len = 0; + size_t read_len = 0; + char buffer[10] = {0}; + char *buffer2 = NULL; + int x; *netstring = NULL; - char buffer[10] = {0}; - /* Peek at first 10 bytes, to get length and colon */ bytes = recv(fd, buffer, 10, MSG_PEEK); @@ -68,8 +70,8 @@ int netstring_read_fd(int fd, char **netstring) return NETSTRING_ERROR_NO_COLON; /* Read the whole string from the buffer */ - size_t read_len = i + len + 1; - char *buffer2 = pkg_malloc(read_len); + read_len = i + len + 1; + buffer2 = pkg_malloc(read_len); if(!buffer2) { LM_ERR("Out of memory!"); return -1; @@ -90,8 +92,6 @@ int netstring_read_fd(int fd, char **netstring) buffer2[read_len - 1] = '\0'; - int x; - for(x = 0; x <= read_len - i - 1; x++) { buffer2[x] = buffer2[x + i]; } _______________________________________________ Kamailio (SER) - Development Mailing List To unsubscribe send an email to sr-dev-le...@lists.kamailio.org