mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-06 11:57:01 +00:00
fix a possible crash caused by not checking if localtime() returned NULL
This commit is contained in:
parent
aedd35f93e
commit
36d2ee8cd9
@ -524,11 +524,17 @@ void save_preview_pane::draw_contents()
|
||||
SDL_BlitSurface(map_surf,NULL,screen,&map_rect);
|
||||
}
|
||||
|
||||
char* old_locale= std::setlocale(LC_TIME, get_locale().localename.c_str());
|
||||
char time_buf[256];
|
||||
const size_t res = strftime(time_buf,sizeof(time_buf),_("%a %b %d %H:%M %Y"),localtime(&((*info_)[index_].time_modified)));
|
||||
if(res == 0) {
|
||||
time_buf[0] = 0;
|
||||
char* old_locale = std::setlocale(LC_TIME, get_locale().localename.c_str());
|
||||
char time_buf[256] = {0};
|
||||
const save_info& save = (*info_)[index_];
|
||||
tm* tm_l = localtime(&save.time_modified);
|
||||
if (tm_l) {
|
||||
const size_t res = strftime(time_buf,sizeof(time_buf),_("%a %b %d %H:%M %Y"),tm_l);
|
||||
if(res == 0) {
|
||||
time_buf[0] = 0;
|
||||
}
|
||||
} else {
|
||||
LOG_NG << "localtime() returned null for time " << save.time_modified << ", save " << save.name;
|
||||
}
|
||||
|
||||
if(old_locale) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user