efl_ui_win: add error hanling code for malloc fail

This commit is contained in:
Jiyoun Park 2017-08-02 16:42:04 +09:00
parent 5c8670fb2b
commit c3d8a1d9f4
1 changed files with 9 additions and 5 deletions

View File

@ -651,11 +651,14 @@ _shot_file_get(Efl_Ui_Win_Data *sd)
{ {
size_t size = sizeof(char) * (strlen(tmp) + 16); size_t size = sizeof(char) * (strlen(tmp) + 16);
repname = malloc(size); repname = malloc(size);
strncpy(repname, tmp, dotptr - tmp); if (repname)
snprintf(repname + (dotptr - tmp), size - {
(dotptr - tmp), "%03i", strncpy(repname, tmp, dotptr - tmp);
sd->shot.shot_counter + 1); snprintf(repname + (dotptr - tmp), size -
strcat(repname, dotptr); (dotptr - tmp), "%03i",
sd->shot.shot_counter + 1);
strcat(repname, dotptr);
}
free(tmp); free(tmp);
return repname; return repname;
} }
@ -666,6 +669,7 @@ _shot_file_get(Efl_Ui_Win_Data *sd)
if (!sd->shot.repeat_count) return strdup("out.png"); if (!sd->shot.repeat_count) return strdup("out.png");
repname = malloc(sizeof(char) * 24); repname = malloc(sizeof(char) * 24);
if (!repname) return NULL;
snprintf(repname, sizeof(char) * 24, "out%03i.png", snprintf(repname, sizeof(char) * 24, "out%03i.png",
sd->shot.shot_counter + 1); sd->shot.shot_counter + 1);