mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 00:12:19 +01:00 
			
		
		
		
	Don't g_assert that localtime() returns non-NULL. It does return NULL at
2005-01-22 Tor Lillqvist <tml@novell.com> * glib/gdate.c (g_date_set_time): Don't g_assert that localtime() returns non-NULL. It does return NULL at least on Win32 if you pass it a negative time_t, which although wrong, shouldn't cause an application to abort. Instead return 2000-01-01 as a default date. Print a warning unless G_DISABLE_CHECKS. (#164622)
This commit is contained in:
		
				
					committed by
					
						 Tor Lillqvist
						Tor Lillqvist
					
				
			
			
				
	
			
			
			
						parent
						
							c9d1c167f4
						
					
				
				
					commit
					76d763485b
				
			| @@ -1,3 +1,11 @@ | ||||
| 2005-01-22  Tor Lillqvist  <tml@novell.com> | ||||
|  | ||||
| 	* glib/gdate.c (g_date_set_time): Don't g_assert that localtime() | ||||
| 	returns non-NULL. It does return NULL at least on Win32 if you | ||||
| 	pass it a negative time_t, which although wrong, shouldn't cause | ||||
| 	an application to abort. Instead return 2000-01-01 as a default | ||||
| 	date. Print a warning unless G_DISABLE_CHECKS. (#164622) | ||||
|  | ||||
| 2005-01-20  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gkeyfile.c (g_key_file_parse_value_as_integer): Don't | ||||
|   | ||||
| @@ -1,3 +1,11 @@ | ||||
| 2005-01-22  Tor Lillqvist  <tml@novell.com> | ||||
|  | ||||
| 	* glib/gdate.c (g_date_set_time): Don't g_assert that localtime() | ||||
| 	returns non-NULL. It does return NULL at least on Win32 if you | ||||
| 	pass it a negative time_t, which although wrong, shouldn't cause | ||||
| 	an application to abort. Instead return 2000-01-01 as a default | ||||
| 	date. Print a warning unless G_DISABLE_CHECKS. (#164622) | ||||
|  | ||||
| 2005-01-20  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gkeyfile.c (g_key_file_parse_value_as_integer): Don't | ||||
|   | ||||
| @@ -1,3 +1,11 @@ | ||||
| 2005-01-22  Tor Lillqvist  <tml@novell.com> | ||||
|  | ||||
| 	* glib/gdate.c (g_date_set_time): Don't g_assert that localtime() | ||||
| 	returns non-NULL. It does return NULL at least on Win32 if you | ||||
| 	pass it a negative time_t, which although wrong, shouldn't cause | ||||
| 	an application to abort. Instead return 2000-01-01 as a default | ||||
| 	date. Print a warning unless G_DISABLE_CHECKS. (#164622) | ||||
|  | ||||
| 2005-01-20  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gkeyfile.c (g_key_file_parse_value_as_integer): Don't | ||||
|   | ||||
| @@ -1,3 +1,11 @@ | ||||
| 2005-01-22  Tor Lillqvist  <tml@novell.com> | ||||
|  | ||||
| 	* glib/gdate.c (g_date_set_time): Don't g_assert that localtime() | ||||
| 	returns non-NULL. It does return NULL at least on Win32 if you | ||||
| 	pass it a negative time_t, which although wrong, shouldn't cause | ||||
| 	an application to abort. Instead return 2000-01-01 as a default | ||||
| 	date. Print a warning unless G_DISABLE_CHECKS. (#164622) | ||||
|  | ||||
| 2005-01-20  Matthias Clasen  <mclasen@redhat.com> | ||||
|  | ||||
| 	* glib/gkeyfile.c (g_key_file_parse_value_as_integer): Don't | ||||
|   | ||||
							
								
								
									
										18
									
								
								glib/gdate.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								glib/gdate.c
									
									
									
									
									
								
							| @@ -884,8 +884,22 @@ g_date_set_time (GDate *d, | ||||
| #else | ||||
|   { | ||||
|     struct tm *ptm = localtime (&t); | ||||
|     g_assert (ptm); | ||||
|     memcpy ((void *) &tm, (void *) ptm, sizeof(struct tm)); | ||||
|  | ||||
|     if (ptm == NULL) | ||||
|       { | ||||
| 	/* Happens at least in Microsoft's C library if you pass a | ||||
| 	 * negative time_t. Use 2000-01-01 as default date. | ||||
| 	 */ | ||||
| #ifndef G_DISABLE_CHECKS | ||||
| 	g_return_if_fail_warning (G_LOG_DOMAIN, "g_date_set_time", "ptm != NULL"); | ||||
| #endif | ||||
|  | ||||
| 	tm.tm_mon = 0; | ||||
| 	tm.tm_mday = 1; | ||||
| 	tm.tm_year = 100; | ||||
|       } | ||||
|     else | ||||
|       memcpy ((void *) &tm, (void *) ptm, sizeof(struct tm)); | ||||
|   } | ||||
| #endif | ||||
|    | ||||
|   | ||||
		Reference in New Issue
	
	Block a user