From: Lucas De Marchi Date: Mon, 18 Nov 2013 13:43:10 +0000 (-0200) Subject: file: use _cleanup_free_ X-Git-Tag: v16~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d3c16c7946e72b8b88cb41b95dc3d014d24f0e8a;p=thirdparty%2Fkmod.git file: use _cleanup_free_ --- diff --git a/libkmod/libkmod-file.c b/libkmod/libkmod-file.c index 390f0183..feb4a151 100644 --- a/libkmod/libkmod-file.c +++ b/libkmod/libkmod-file.c @@ -175,13 +175,12 @@ static int load_zlib(struct kmod_file *file) { int err = 0; off_t did = 0, total = 0; - unsigned char *p = NULL; + _cleanup_free_ unsigned char *p = NULL; errno = 0; file->gzf = gzdopen(file->fd, "rb"); - if (file->gzf == NULL) { + if (file->gzf == NULL) return -errno; - } file->fd = -1; /* now owned by gzf due gzdopen() */ for (;;) { @@ -215,9 +214,10 @@ static int load_zlib(struct kmod_file *file) file->memory = p; file->size = did; + p = NULL; return 0; + error: - free(p); gzclose(file->gzf); return err; }