mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-27 02:05:47 +01:00
WPrefs: fix memory leak in loadRImage (Coverity #50107)
As pointed by Coverity, if there is a problem when reading the binary data of an RImage from a file, the area allocated to store it would not be freed. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
a9e2923f67
commit
c54bb11ee9
@@ -1276,13 +1276,13 @@ static Pixmap loadRImage(WMScreen * scr, const char *path)
|
|||||||
}
|
}
|
||||||
image = RCreateImage(w, h, d == 4);
|
image = RCreateImage(w, h, d == 4);
|
||||||
read_size = w * h * d;
|
read_size = w * h * d;
|
||||||
if (fread(image->data, 1, read_size, f) != read_size) {
|
if (fread(image->data, 1, read_size, f) == read_size)
|
||||||
fclose(f);
|
RConvertImage(WMScreenRContext(scr), image, &pixmap);
|
||||||
return None;
|
else
|
||||||
}
|
pixmap = None;
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
RConvertImage(WMScreenRContext(scr), image, &pixmap);
|
|
||||||
RReleaseImage(image);
|
RReleaseImage(image);
|
||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
|
|||||||
Reference in New Issue
Block a user