From 49a9f7f263b70dc489f843059000c1f5d732d5db Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 21 Jul 2023 14:01:57 +0800 Subject: [PATCH] Allocate new unsigned char buffer for processed line in heap, fixing crash Signed-off-by: Claudio Cambra --- .../NCDesktopClientSocketKit/LocalSocketClient.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell_integration/MacOSX/NextcloudIntegration/NCDesktopClientSocketKit/LocalSocketClient.m b/shell_integration/MacOSX/NextcloudIntegration/NCDesktopClientSocketKit/LocalSocketClient.m index 1d94f8d3a..b2408cb62 100644 --- a/shell_integration/MacOSX/NextcloudIntegration/NCDesktopClientSocketKit/LocalSocketClient.m +++ b/shell_integration/MacOSX/NextcloudIntegration/NCDesktopClientSocketKit/LocalSocketClient.m @@ -343,9 +343,10 @@ if (firstSeparatorIndex.location == NSNotFound) { NSLog(@"No separator found. Creating new buffer qith space for null terminator."); - unsigned char newBuffer[inBufferLength + 1]; - memcpy(&newBuffer, buffer, inBufferLength); - buffer = &newBuffer[0]; + + unsigned char *newBuffer = malloc(sizeof(unsigned char) * (inBufferLength + 1)); + memcpy(newBuffer, buffer, inBufferLength); + buffer = newBuffer; nullTerminatorIndex = inBufferLength; } else { nullTerminatorIndex = firstSeparatorIndex.location; -- 2.30.2