Skip to content

Commit 80821c1

Browse files
author
duke
committedOct 13, 2023
Automatic merge of jdk:master into master
2 parents 1cf0eb3 + ff0b397 commit 80821c1

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed
 

‎src/java.base/aix/native/libnio/MappedMemoryUtils.c

+10
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ static void check_aix_einval(JNIEnv* env, void* end_address)
158158
FILE* proc_file;
159159
{
160160
char* fname = (char*) malloc(sizeof(char) * PFNAME_LEN);
161+
if (fname == NULL) {
162+
JNU_ThrowOutOfMemoryError(env, NULL);
163+
return;
164+
}
165+
161166
pid_t the_pid = getpid();
162167
jio_snprintf(fname, PFNAME_LEN, "/proc/%d/map", the_pid);
163168
proc_file = fopen(fname, "r");
@@ -170,6 +175,11 @@ static void check_aix_einval(JNIEnv* env, void* end_address)
170175
}
171176
{
172177
prmap_t* map_entry = (prmap_t*) malloc(sizeof(prmap_t));
178+
if (map_entry == NULL) {
179+
JNU_ThrowOutOfMemoryError(env, NULL);
180+
fclose(proc_file);
181+
return;
182+
}
173183
check_proc_map_array(env, proc_file, map_entry, end_address);
174184
free(map_entry);
175185
}

‎src/java.base/unix/native/libjava/java_props_md.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -238,6 +238,11 @@ static int ParseLocale(JNIEnv* env, int cat, char ** std_language, char ** std_s
238238
*std_language = "en";
239239
if (language != NULL && mapLookup(language_names, language, std_language) == 0) {
240240
*std_language = malloc(strlen(language)+1);
241+
if (*std_language == NULL) {
242+
free(encoding_variant);
243+
JNU_ThrowOutOfMemoryError(env, NULL);
244+
return 0;
245+
}
241246
strcpy(*std_language, language);
242247
}
243248
}
@@ -246,6 +251,11 @@ static int ParseLocale(JNIEnv* env, int cat, char ** std_language, char ** std_s
246251
if (std_country != NULL && country != NULL) {
247252
if (mapLookup(country_names, country, std_country) == 0) {
248253
*std_country = malloc(strlen(country)+1);
254+
if (*std_country == NULL) {
255+
free(encoding_variant);
256+
JNU_ThrowOutOfMemoryError(env, NULL);
257+
return 0;
258+
}
249259
strcpy(*std_country, country);
250260
}
251261
}

‎src/java.base/windows/native/libjli/cmdtoargs.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -324,6 +324,10 @@ class Vector {
324324
bool check() {
325325
// "pgmname" rest of cmdline ie. pgmname + 2 double quotes + space + cmdline from windows
326326
char* cptr = (char*) malloc(strlen(argv[0]) + sizeof(char) * 3 + strlen(cmdline) + 1);
327+
if (cptr == NULL) {
328+
printf("*** cannot allocate memory\n");
329+
doabort();
330+
}
327331
_snprintf(cptr, MAX_PATH, "\"%s\" %s", argv[0], cmdline);
328332
JLI_CmdToArgs(cptr);
329333
free(cptr);

‎src/java.base/windows/native/libnio/ch/UnixDomainSockets.c

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ Java_sun_nio_ch_UnixDomainSockets_init(JNIEnv *env, jclass cl)
118118
if (result == SOCKET_ERROR) {
119119
if (GetLastError() == WSAENOBUFS) {
120120
infoPtr = (LPWSAPROTOCOL_INFOW)malloc(len);
121+
if (infoPtr == NULL) {
122+
return JNI_FALSE;
123+
}
121124
result = WSAEnumProtocolsW(0, infoPtr, &len);
122125
if (result == SOCKET_ERROR) {
123126
free(infoPtr);

0 commit comments

Comments
 (0)
Please sign in to comment.