8332589: ubsan: unix/native/libjava/ProcessImpl_md.c:562:5: runtime error: null pointer passed as argument 2, which is declared to never be null

Reviewed-by: rriggs, mdoerr
This commit is contained in:
Matthias Baesken 2024-05-27 06:35:39 +00:00
parent 4e8deb396e
commit 16dba04e8d

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -559,8 +559,17 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath)
}
offset = copystrings(buf, 0, &c->argv[0]);
offset = copystrings(buf, offset, &c->envv[0]);
memcpy(buf+offset, c->pdir, sp.dirlen);
offset += sp.dirlen;
if (c->pdir != NULL) {
if (sp.dirlen > 0) {
memcpy(buf+offset, c->pdir, sp.dirlen);
offset += sp.dirlen;
}
} else {
if (sp.dirlen > 0) {
free(buf);
return -1;
}
}
offset = copystrings(buf, offset, parentPathv);
assert(offset == bufsize);