Thread (8 messages) 8 messages, 2 authors, 2021-12-03
STALE1643d

[PATCH 1/6] e2fsck: set s->len=0 if malloc() fails in alloc_string()

From: zhanchengbin <hidden>
Date: 2021-12-03 06:26:20
Subsystem: the rest · Maintainer: Linus Torvalds

In alloc_string(), when malloc fails, len in the
string structure should be 0.

Signed-off-by: zhanchengbin <redacted>
Signed-off-by: Zhiqiang Liu <redacted>
---
  e2fsck/logfile.c | 2 ++
  1 file changed, 2 insertions(+)
diff --git a/e2fsck/logfile.c b/e2fsck/logfile.c
index 63e9a12f..f2227ad5 100644
--- a/e2fsck/logfile.c
+++ b/e2fsck/logfile.c
@@ -32,6 +32,8 @@ static void alloc_string(struct string *s, int len)
  {
      s->s = malloc(len);
  /* e2fsck_allocate_memory(ctx, len, "logfile name"); */
+    if (s->s == NULL)
+        s->len = 0;
      s->len = len;
      s->end = 0;
  }
-- 
2.23.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help