src/solaris/native/java/lang/UNIXProcess_md.c
Print this page
*** 243,265 ****
--- 243,280 ----
static const char * const *
splitPath(JNIEnv *env, const char *path)
{
const char *p, *q;
char **pathv;
+ static const char * const cwd = "./";
int i;
int count = countOccurrences(path, ':') + 1;
pathv = NEW(char*, count+1);
+ if (pathv == NULL)
+ return NULL;
+
pathv[count] = NULL;
for (p = path, i = 0; i < count; i++, p = q + 1) {
for (q = p; (*q != ':') && (*q != '\0'); q++)
;
+
if (q == p) /* empty PATH component => "." */
pathv[i] = "./";
else {
int addSlash = ((*(q - 1)) != '/');
pathv[i] = NEW(char, q - p + addSlash + 1);
+
+ if (pathv[i] == NULL) {
+
+ for (i--; i >= 0; i--)
+ if (pathv[i] != cwd)
+ free(pathv[i]);
+
+ return NULL;
+ }
+
memcpy(pathv[i], p, q - p);
if (addSlash)
pathv[i][q - p] = '/';
pathv[i][q - p + addSlash] = '\0';
}
*** 484,493 ****
--- 499,511 ----
if (strcmp(s, "Unknown error") != 0)
detail = s;
}
/* ASCII Decimal representation uses 2.4 times as many bits as binary. */
errmsg = NEW(char, strlen(format) + strlen(detail) + 3 * sizeof(errnum));
+ if (errmsg == NULL)
+ return;
+
sprintf(errmsg, format, errnum, detail);
s = JNU_NewStringPlatform(env, errmsg);
if (s != NULL) {
jobject x = JNU_NewObjectByName(env, "java/io/IOException",
"(Ljava/lang/String;)V", s);