mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-12 14:29:28 +00:00
lpr(1): small bounds check with reallocarray(3).
While here plug a memory leak upon error and postpose a multiplication until after reallocation has succeded. Hinted partially by: OpenBSD Reviewed by: gad MFC after: 2 weeks
This commit is contained in:
parent
14984031b7
commit
4fd444b072
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=314877
@ -167,11 +167,13 @@ getq(const struct printer *pp, struct jobqueue *(*namelist[]))
|
||||
* realloc the maximum size.
|
||||
*/
|
||||
if (++nitems > arraysz) {
|
||||
arraysz *= 2;
|
||||
queue = (struct jobqueue **)realloc((char *)queue,
|
||||
arraysz * sizeof(struct jobqueue *));
|
||||
if (queue == NULL)
|
||||
queue = (struct jobqueue **)reallocarray((char *)queue,
|
||||
arraysz, 2 * sizeof(struct jobqueue *));
|
||||
if (queue == NULL) {
|
||||
free(q);
|
||||
goto errdone;
|
||||
}
|
||||
arraysz *= 2;
|
||||
}
|
||||
queue[nitems-1] = q;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user