summaryrefslogtreecommitdiffstats
path: root/65.patch
blob: 43fed808ebab44c92c40328e751a346e2e94c5a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From d3afedb016aa319246177a3c516ca4804f08dd45 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 22 Feb 2019 15:19:18 +0100
Subject: [PATCH] fix string free

---
 .gitignore  | 2 ++
 smbclient.c | 6 ++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/smbclient.c b/smbclient.c
index 81ebd5a..faeb505 100644
--- a/smbclient.c
+++ b/smbclient.c
@@ -1345,15 +1345,17 @@ PHP_FUNCTION(smbclient_read)
 
 	if ((ZSTR_LEN(buf) = smbc_read(state->ctx, file, ZSTR_VAL(buf), count)) >= 0) {
 		RETURN_STR(buf);
+	}
+	zend_string_release(buf);
 #else
 	void *buf = emalloc(count);
 	ssize_t nbytes;
 
 	if ((nbytes = smbc_read(state->ctx, file, buf, count)) >= 0) {
 		RETURN_STRINGL(buf, nbytes, 0);
-#endif
 	}
 	efree(buf);
+#endif
 	switch (state->err = errno) {
 		case EISDIR: php_error(E_WARNING, "Read error: Is a directory"); break;
 		case EBADF: php_error(E_WARNING, "Read error: Not a valid file resource or not open for reading"); break;
@@ -1738,7 +1740,7 @@ PHP_FUNCTION(smbclient_removexattr)
 PHP_FUNCTION(smbclient_option_get)
 {
 	zend_long option;
-	char *ret;
+	const char *ret;
 	zval *zstate;
 	php_smbclient_state *state;