diff options
| author | Hung-Weic Chiu <sppsorrg@gmail.com> | 2017-04-29 15:02:31 +0000 |
|---|---|---|
| committer | Hung-Weic Chiu <sppsorrg@gmail.com> | 2017-04-29 15:02:31 +0000 |
| commit | 5d6cc38ca36538583ff4c464c46a7c6de08608b6 (patch) | |
| tree | fe6169f11f6beee69bbc1464eca367547e67af5d /lib/imsg-buffer.c | |
| parent | d8d58e98397d8442ec68f8d715b64d5e6000b903 (diff) | |
Fix the "Use-after-free" of clang SA.
- Set the pointer to NULL after free it, otherwise the pointer will be accessed again. (since not null)
Signed-off-by: Hung-Weic Chiu <sppsorrg@gmail.com>
Diffstat (limited to 'lib/imsg-buffer.c')
| -rw-r--r-- | lib/imsg-buffer.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/imsg-buffer.c b/lib/imsg-buffer.c index a486fc17c1..f7b9f63778 100644 --- a/lib/imsg-buffer.c +++ b/lib/imsg-buffer.c @@ -209,8 +209,10 @@ msgbuf_clear(struct msgbuf *msgbuf) { struct ibuf *buf; - while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL) + while ((buf = TAILQ_FIRST(&msgbuf->bufs)) != NULL) { ibuf_dequeue(msgbuf, buf); + TAILQ_FIRST(&msgbuf->bufs) = NULL; + } } int |
