1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-06 10:13:13 +02:00

Get rid of unneeded buffer copying, if Jansson library >= v2.1

This commit is contained in:
Bram Matthys
2023-04-01 12:29:59 +02:00
parent 275cb97cfc
commit 7d7974f800
+6 -1
View File
@@ -531,14 +531,19 @@ void rpc_close(Client *client)
*/
void rpc_call_text(Client *client, const char *readbuf, int len)
{
char buf[2048];
json_t *request = NULL;
json_error_t jerr;
#if JANSSON_VERSION_HEX >= 0x020100
const char *buf = readbuf;
request = json_loadb(buf, len, JSON_REJECT_DUPLICATES, &jerr);
#else
char buf[2048];
*buf = '\0';
strlncpy(buf, readbuf, sizeof(buf), len);
request = json_loads(buf, JSON_REJECT_DUPLICATES, &jerr);
#endif
if (!request)
{
unreal_log(ULOG_INFO, "rpc", "RPC_INVALID_JSON", client,