From: Adam Richter <adamrichter4@gmail.com>
To: emacs-devel@gnu.org
Subject: Untested patch for trivial memory leak in update-game-score.c
Date: Tue, 30 Apr 2019 14:21:56 -0700 [thread overview]
Message-ID: <CAGn-TghtVe5APXmF5iQKPEXaW41+cDCKoXTXdRYUuH1iY3LLyw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 632 bytes --]
Hi, everyone.
Attached is a patch to update-games-score.c for trivial memory leaks
found by cppcheck. In the hopes of expediting integration, I hereby
release my interest in this patch into the public domain.
As far as I can tell, update-game-score.c is not compiled when I build
emacs, so the purpose of this patch might mostly be to clean up
cppcheck output, but I did compile my modified version of the file
manually, and gcc -Wall had no complaints, although gcc -Wextra
complained about some signed/unsigned comparisons and unlock_file()
ignoring its filename parameter.
Thanks in advance for considering this patch.
Adam
[-- Attachment #2: emacs.update-games-score.diff --]
[-- Type: text/x-diff, Size: 649 bytes --]
--- lib-src/update-game-score.c.orig 2019-01-07 06:26:06.000000000 -0800
+++ lib-src/update-game-score.c 2019-04-30 12:34:23.459986134 -0700
@@ -325,16 +325,21 @@ read_scores (const char *filename, struc
nread = fread (filedata, 1, filesize + 1, f);
if (filesize < nread)
{
+ free (filedata);
errno = 0;
return -1;
}
if (nread < filesize)
filesize = nread;
if (ferror (f) || fclose (f) != 0)
- return -1;
+ {
+ free (filedata);
+ return -1;
+ }
filedata[filesize] = 0;
if (strlen (filedata) != filesize)
{
+ free (filedata);
errno = 0;
return -1;
}
next reply other threads:[~2019-04-30 21:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-30 21:21 Adam Richter [this message]
2019-05-01 15:11 ` Untested patch for trivial memory leak in update-game-score.c Tadeus Prastowo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGn-TghtVe5APXmF5iQKPEXaW41+cDCKoXTXdRYUuH1iY3LLyw@mail.gmail.com \
--to=adamrichter4@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.