diff --git a/lib/libjail/jail.c b/lib/libjail/jail.c index 6a35cdc6dde5..3e0c2a0f98cb 100644 --- a/lib/libjail/jail.c +++ b/lib/libjail/jail.c @@ -262,7 +262,10 @@ jailparam_all(struct jailparam **jpp) goto error; mib1[1] = 2; } - jp = reallocarray(jp, njp, sizeof(*jp)); + /* Just return the untrimmed buffer if reallocarray() somehow fails. */ + tjp = reallocarray(jp, njp, sizeof(*jp)); + if (tjp != NULL) + jp = tjp; *jpp = jp; return (njp);