mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-10 15:54:17 +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);
|
||||
read_size = w * h * d;
|
||||
if (fread(image->data, 1, read_size, f) != read_size) {
|
||||
fclose(f);
|
||||
return None;
|
||||
}
|
||||
if (fread(image->data, 1, read_size, f) == read_size)
|
||||
RConvertImage(WMScreenRContext(scr), image, &pixmap);
|
||||
else
|
||||
pixmap = None;
|
||||
|
||||
fclose(f);
|
||||
|
||||
RConvertImage(WMScreenRContext(scr), image, &pixmap);
|
||||
RReleaseImage(image);
|
||||
|
||||
return pixmap;
|
||||
|
||||
Reference in New Issue
Block a user