ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

commit 1b155f0e6906eaa70a28f6496d8da6c3c6797890
parent d8a22709fb90dc99fc8cd4f29ce010035fd10d1f
Author: Frederic Cambus <fred@statdns.com>
Date:   Thu, 22 Oct 2020 20:18:47 +0200

Check strdup() return value and error out on failed allocation.

Diffstat:
Msrc/ansilove.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/ansilove.c b/src/ansilove.c @@ -329,6 +329,8 @@ main(int argc, char *argv[]) /* get file extension */ char *fext = strrchr(input, '.'); fext = fext ? strtolower(strdup(++fext)) : strdup(""); + if (!fext) + errx(EXIT_FAILURE, "Memory allocation error."); /* check if current file has a .diz extension */ if (!strcmp(fext, "diz"))