< prev index next >
src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.c
Print this page
rev 56159 : 8230480: check malloc/calloc results in java.desktop
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -64,10 +64,13 @@
static GtkLib** load_order;
static int n_libs = 0;
if (!n_libs) {
n_libs = sizeof(gtk_libs) / sizeof(GtkLib);
load_order = calloc(n_libs + 1, sizeof(GtkLib *));
+ if (load_order == NULL) {
+ return NULL;
+ }
}
int i, first = 0;
for (i = 0; i < n_libs; i++) {
load_order[i] = >k_libs[i];
if (load_order[i]->version == version) {
@@ -83,10 +86,11 @@
return load_order;
}
static GtkLib* get_loaded() {
GtkLib** libs = get_libs_order(GTK_ANY);
+ if (libs == NULL) return NULL;
while(!gtk && *libs) {
GtkLib* lib = *libs++;
if (lib->check(lib->vname, /* load = */FALSE)) {
return lib;
}
@@ -109,11 +113,11 @@
if (!gtk) {
gtk = lib->load(env, lib->name);
}
} else {
GtkLib** libs = get_libs_order(version);
- while (!gtk && *libs) {
+ while (!gtk && libs && *libs) {
lib = *libs++;
if (version == GTK_ANY || lib->version == version) {
if (verbose) {
fprintf(stderr, "Looking for GTK%d library...\n",
lib->version);
@@ -139,10 +143,11 @@
return gtk != NULL;
}
static gboolean check_version(GtkVersion version) {
GtkLib** libs = get_libs_order(version);
+ if (libs == NULL) return FALSE;
while (*libs) {
GtkLib* lib = *libs++;
if (lib->check(lib->vname, /* load = */TRUE)) {
return TRUE;
}
< prev index next >