Closed RevySR closed 1 week ago
I more generic terms, ext_clipboard_provide_msg.length
is size_t
regardless of platform, but the function takes unsigned long
.
Did you read CONTRIBUTING.md?
I more generic terms,
ext_clipboard_provide_msg.length
issize_t
regardless of platform, but the function takesunsigned long
.Did you read CONTRIBUTING.md?
Sorry, I misunderstood the CONTRIBUTING document and have resubmitted a new commit msg.
I think there may still be some misunderstanding regarding the structure of commit messages.
To clarify: A good commit message says what was done in the title. E.g. "server: Use correct type for length in compress()". Then, it goes on to say why. E.g. "This fixes data type mismatch on 32 bit systems".
Besides, there exists a simpler solution:
diff --git a/src/server.c b/src/server.c
index ac15b0b..b94ed0d 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1509,9 +1509,8 @@ static void ext_clipboard_save_provide_msg(struct nvnc* server, const char* text
memcpy(provide_msg_buf + 4, text, len);
provide_msg_buf[provide_msg_len - 1] = 0;
- server->ext_clipboard_provide_msg.length = compressBound(provide_msg_len);
- server->ext_clipboard_provide_msg.buffer = malloc(
- server->ext_clipboard_provide_msg.length);
+ unsigned long length = compressBound(provide_msg_len);
+ server->ext_clipboard_provide_msg.buffer = malloc(length);
if (!server->ext_clipboard_provide_msg.buffer) {
nvnc_log(NVNC_LOG_ERROR, "OOM: %m");
return;
@@ -1519,8 +1518,8 @@ static void ext_clipboard_save_provide_msg(struct nvnc* server, const char* text
int rc;
rc = compress((unsigned char*)server->ext_clipboard_provide_msg.buffer,
- &server->ext_clipboard_provide_msg.length,
- provide_msg_buf, provide_msg_len);
+ &length, provide_msg_buf, provide_msg_len);
+ server->ext_clipboard_provide_msg.length = length;
free(provide_msg_buf);
This fixes data type mismatch on 32 bit systems
Thanks for your help. I've changed it.
Thanks! N.b. it would have been fine to include the compiler error in the message, but this is good enough.
I hope you gave this a quick test, because I sure didn't. :)
In i386 ext_clipboard_provide_msg.length is size_t, not uLongf(long unsigned int).