[PATCH 5/7] libss: handle memory allcation failure in ss_help()
From: Lukas Czerner <hidden>
Date: 2021-08-06 09:58:41
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
From: Lukas Czerner <hidden>
Date: 2021-08-06 09:58:41
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
Signed-off-by: Lukas Czerner <redacted> --- lib/ss/help.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/ss/help.c b/lib/ss/help.c
index 96eb1092..a22b4017 100644
--- a/lib/ss/help.c
+++ b/lib/ss/help.c@@ -96,7 +96,12 @@ void ss_help(int argc, char const * const *argv, int sci_idx, pointer info_ptr) } if (fd < 0) { #define MSG "No info found for " - char *buf = malloc(strlen (MSG) + strlen (argv[1]) + 1); + char *buf = malloc(strlen (MSG) + strlen (argv[1]) + 1); + if (!buf) { + ss_perror(sci_idx, 0, + "couldn't allocate memory to print error message"); + return; + } strcpy(buf, MSG); strcat(buf, argv[1]); ss_perror(sci_idx, 0, buf);
--
2.31.1