git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 12/13] Handled git pipeline errors - Memory leak

From
Haritha D via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 13, 2023, 10:24 UTC
Message-ID
<06658ebad1027cdc72d9dc013b7a022245dd22c9.1699871056.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1537.git.git.1699871056.gitgitgadget@gmail.com>
From: Haritha D <harithamma.d@ibm.com>
This PR has fixes to enable build on z/OS
Signed-off-by: Harithamma D <harithamma.d@ibm.com>
---
 convert.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/convert.c b/convert.c
index 16173a1caf6..4c034bb714c 100644
--- a/convert.c
+++ b/convert.c
@@ -1313,9 +1313,9 @@ static int git_path_check_ident(struct attr_check_item *check)
 
 static struct attr_check *check;
 
-static const char* get_platform(void) {
+static void get_platform(char** result) {
 	struct utsname uname_info;
-	char *result = NULL;
+	*result = NULL;
 
 	if (uname(&uname_info) < 0)
 		die(_("uname() failed with error '%s' (%d)\n"),
@@ -1325,10 +1325,10 @@ static const char* get_platform(void) {
 	if(*uname_info.sysname != '\0')
 	{
 		int index=0;
-		result = (char *)malloc(strlen(uname_info.sysname)+1);
+		*result = (char *)malloc(strlen(uname_info.sysname)+1);
 		while(index <= strlen(uname_info.sysname))
 		{
-			result[index] = uname_info.sysname[index];
+			(*result)[index] = uname_info.sysname[index];
 			index++;
 		}
 	}
@@ -1336,9 +1336,8 @@ static const char* get_platform(void) {
 
 #ifdef __MVS__
 	if (!strcmp(uname_info.sysname, "OS/390"))
-		result="zos";
+		*result = "zos";
 #endif
-	return (char*)result;
 }
 
 
@@ -1347,8 +1346,11 @@ void convert_attrs(struct index_state *istate,
 {
 	struct attr_check_item *ccheck = NULL;
 	struct strbuf platform_working_tree_encoding = STRBUF_INIT;
-
-	strbuf_addf(&platform_working_tree_encoding, "%s-working-tree-encoding", get_platform());
+	char* result=NULL;
+	get_platform(&result);
+	strbuf_addf(&platform_working_tree_encoding, "%s-working-tree-encoding", result);
+	if (result != NULL)
+		free (result);
 
 	if (!check) {
 		check = attr_check_initl("crlf", "ident", "filter",
-- 
gitgitgadget
Previous: Haritha D via GitGitGadgetNext: Haritha D via GitGitGadget
Message 17 of 21 in “Enabling z/OS workflow for git”
  1. 00/13 Enabling z/OS workflow for gitHaritha via GitGitGadget, Nov 13, 2023
  2. 01/13 Enabling z/OS workflow for gitHaritha D via GitGitGadget, Nov 13, 2023
  3. 03/13 spaces and errors fix Handled git pipeline errorsHaritha D via GitGitGadget, Nov 13, 2023
  4. Junio C HamanoNov 14, 2023
  5. 04/13 fixes for build errors Handled git pipeline errorseHaritha D via GitGitGadget, Nov 13, 2023
  6. 05/13 fixes for build errorsHaritha D via GitGitGadget, Nov 13, 2023
  7. 06/13 spaces and errors fix Handled git pipeline errorsHaritha D via GitGitGadget, Nov 13, 2023
  8. 02/13 Enable builds for z/OS.Haritha D via GitGitGadget, Nov 13, 2023
  9. brian m. carlsonNov 13, 2023
  10. Junio C HamanoNov 14, 2023
  11. Junio C HamanoNov 14, 2023
  12. 07/13 spaces and errors fix Handled git pipeline errorsHaritha D via GitGitGadget, Nov 13, 2023
  13. 08/13 platform_name fix Handled git pipeline errorsHaritha D via GitGitGadget, Nov 13, 2023
  14. 09/13 strncpy fix Handled git pipeline errorsHaritha D via GitGitGadget, Nov 13, 2023
  15. 10/13 strncpy fix Handled git pipeline errorsHaritha D via GitGitGadget, Nov 13, 2023
  16. 11/13 strncpy fix Handled git pipeline errorsHaritha D via GitGitGadget, Nov 13, 2023
  17. 12/13 Handled git pipeline errors - Memory leakHaritha D via GitGitGadget, Nov 13, 2023
  18. 13/13 Handled git pipeline errors - z/OS enableHaritha D via GitGitGadget, Nov 13, 2023
  19. This PR enables a successful git build on z/OS.Haritha via GitGitGadget, Dec 4, 2023
  20. Eric SunshineDec 4, 2023
  21. René ScharfeDec 5, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.