summaryrefslogtreecommitdiff
path: root/src/lib/elm_win.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/elm_win.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 8b9644b4c..354c7b673 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -144,9 +144,10 @@ _shot_file_get(Elm_Win *win)
144 char *dotptr = strrchr(tmp, '.'); 144 char *dotptr = strrchr(tmp, '.');
145 if (dotptr) 145 if (dotptr)
146 { 146 {
147 repname = malloc(sizeof(char)*(strlen(tmp) + 16)); 147 size_t size = sizeof(char)*(strlen(tmp) + 16);
148 repname = malloc(size);
148 strncpy(repname, tmp, dotptr - tmp); 149 strncpy(repname, tmp, dotptr - tmp);
149 sprintf(repname + (dotptr - tmp), "%03i", 150 snprintf(repname + (dotptr - tmp), size - (dotptr - tmp), "%03i",
150 win->shot.shot_counter + 1); 151 win->shot.shot_counter + 1);
151 strcat(repname, dotptr); 152 strcat(repname, dotptr);
152 free(tmp); 153 free(tmp);
@@ -157,12 +158,10 @@ _shot_file_get(Elm_Win *win)
157 } 158 }
158 free(tmp); 159 free(tmp);
159 if (!win->shot.repeat_count) return strdup("out.png"); 160 if (!win->shot.repeat_count) return strdup("out.png");
160 else 161
161 { 162 repname = malloc(sizeof(char) * 24);
162 repname = malloc(sizeof(char) * 24); 163 snprintf(repname, sizeof(char) * 24, "out%03i.png", win->shot.shot_counter + 1);
163 sprintf(repname, "out%03i.png", win->shot.shot_counter + 1); 164 return repname;
164 return repname;
165 }
166} 165}
167 166
168static int 167static int