mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 08:22:16 +01:00 
			
		
		
		
	Avoid memory leaks in borderline cases. (#172612, Morten Welinder)
2005-04-05 Matthias Clasen <mclasen@redhat.com> * glib/gfileutils.c (get_contents_stdio): Avoid memory leaks in borderline cases. (#172612, Morten Welinder)
This commit is contained in:
		
				
					committed by
					
						 Matthias Clasen
						Matthias Clasen
					
				
			
			
				
	
			
			
			
						parent
						
							112be25742
						
					
				
				
					commit
					4fe1315d5e
				
			| @@ -1,3 +1,8 @@ | ||||
| 2005-04-05  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gfileutils.c (get_contents_stdio): Avoid memory  | ||||
| 	leaks in borderline cases.  (#172612, Morten Welinder) | ||||
|  | ||||
| 2005-04-04  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gconvert.c: Clarify docs in some places. (#172404,  | ||||
|   | ||||
| @@ -1,3 +1,8 @@ | ||||
| 2005-04-05  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gfileutils.c (get_contents_stdio): Avoid memory  | ||||
| 	leaks in borderline cases.  (#172612, Morten Welinder) | ||||
|  | ||||
| 2005-04-04  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gconvert.c: Clarify docs in some places. (#172404,  | ||||
|   | ||||
| @@ -1,3 +1,8 @@ | ||||
| 2005-04-05  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gfileutils.c (get_contents_stdio): Avoid memory  | ||||
| 	leaks in borderline cases.  (#172612, Morten Welinder) | ||||
|  | ||||
| 2005-04-04  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gconvert.c: Clarify docs in some places. (#172404,  | ||||
|   | ||||
| @@ -1,3 +1,8 @@ | ||||
| 2005-04-05  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gfileutils.c (get_contents_stdio): Avoid memory  | ||||
| 	leaks in borderline cases.  (#172612, Morten Welinder) | ||||
|  | ||||
| 2005-04-04  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gconvert.c: Clarify docs in some places. (#172404,  | ||||
|   | ||||
| @@ -473,6 +473,7 @@ get_contents_stdio (const gchar *display_filename, | ||||
|   gchar *str = NULL; | ||||
|   size_t total_bytes = 0; | ||||
|   size_t total_allocated = 0; | ||||
|   gchar *tmp; | ||||
|  | ||||
|   g_assert (f != NULL); | ||||
|  | ||||
| @@ -490,9 +491,9 @@ get_contents_stdio (const gchar *display_filename, | ||||
|           else | ||||
|             total_allocated = MIN (bytes + 1, sizeof (buf)); | ||||
|  | ||||
|           str = g_try_realloc (str, total_allocated); | ||||
|           tmp = g_try_realloc (str, total_allocated); | ||||
|  | ||||
|           if (str == NULL) | ||||
|           if (tmp == NULL) | ||||
|             { | ||||
|               g_set_error (error, | ||||
|                            G_FILE_ERROR, | ||||
| @@ -503,6 +504,8 @@ get_contents_stdio (const gchar *display_filename, | ||||
|  | ||||
|               goto error; | ||||
|             } | ||||
|  | ||||
| 	  str = tmp; | ||||
|         } | ||||
|  | ||||
|       if (ferror (f)) | ||||
| @@ -523,7 +526,7 @@ get_contents_stdio (const gchar *display_filename, | ||||
|  | ||||
|   fclose (f); | ||||
|  | ||||
|   if (total_bytes == 0) | ||||
|   if (total_allocated == 0) | ||||
|     str = g_new (gchar, 1); | ||||
|  | ||||
|   str[total_bytes] = '\0'; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user