Check for NULL before dereferencing the pointer

In case of an error the whole frame is freed, break out of the loop to
return early.
This commit is contained in:
Rene Kita
2022-02-13 10:49:23 +01:00
parent 9f5c311e45
commit 1308f5efe5

View File

@@ -426,11 +426,13 @@ fb_frame_new(int w, int h, int n)
for (i = 0; i < n; i++) {
frame[i] = fb_image_new(w, h);
if (frame[i] == NULL) {
error = 1;
break;
}
frame[i]->num = n;
frame[i]->id = i;
frame[i]->delay = 1000;
if (frame[i] == NULL)
error = 1;
}
if (error) {