< prev index next >

src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c

Print this page
rev 56362 : 8231445: check ZALLOC return values in awt coding

*** 164,173 **** --- 164,177 ---- mask, vinfo, &visualsMatched); if (visualList) { int id = -1; VisualID defaultVisual = XVisualIDFromVisual(DefaultVisual(awt_display, vinfo->screen)); defaultConfig = ZALLOC(_AwtGraphicsConfigData); + if (defaultConfig == NULL) { + XFree(visualList); + return NULL; + } for (i = 0; i < visualsMatched; i++) { memcpy(&defaultConfig->awt_visInfo, &visualList[i], sizeof(XVisualInfo)); defaultConfig->awt_depth = visualList[i].depth; /* we can't use awtJNI_CreateColorData here, because it'll pull,
*** 445,456 **** /* Skip the non-supported 12-bit TrueColor visual */ continue; } else { ind = nConfig++; } ! graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); ! graphicsConfigs [ind]->awt_depth = pVITrue [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVITrue [i], sizeof (XVisualInfo)); if (xrenderFindVisualFormat != NULL) { XRenderPictFormat *format = xrenderFindVisualFormat (awt_display, pVITrue [i].visual); --- 449,464 ---- /* Skip the non-supported 12-bit TrueColor visual */ continue; } else { ind = nConfig++; } ! graphicsConfigs[ind] = ZALLOC (_AwtGraphicsConfigData); ! if (graphicsConfigs[ind] == NULL) { ! JNU_ThrowOutOfMemoryError(env, "allocation in getAllConfigs failed"); ! goto cleanup; ! } ! graphicsConfigs[ind]->awt_depth = pVITrue [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVITrue [i], sizeof (XVisualInfo)); if (xrenderFindVisualFormat != NULL) { XRenderPictFormat *format = xrenderFindVisualFormat (awt_display, pVITrue [i].visual);
*** 480,491 **** XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); ! graphicsConfigs [ind]->awt_depth = pVI8p [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8p [i], sizeof (XVisualInfo)); } for (i = 0; i < n12p; i++) { --- 488,503 ---- XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs[ind] = ZALLOC (_AwtGraphicsConfigData); ! if (graphicsConfigs[ind] == NULL) { ! JNU_ThrowOutOfMemoryError(env, "allocation in getAllConfigs failed"); ! goto cleanup; ! } ! graphicsConfigs[ind]->awt_depth = pVI8p [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8p [i], sizeof (XVisualInfo)); } for (i = 0; i < n12p; i++) {
*** 493,504 **** XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); ! graphicsConfigs [ind]->awt_depth = pVI12p [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI12p [i], sizeof (XVisualInfo)); } for (i = 0; i < n8s; i++) { --- 505,520 ---- XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs[ind] = ZALLOC (_AwtGraphicsConfigData); ! if (graphicsConfigs[ind] == NULL) { ! JNU_ThrowOutOfMemoryError(env, "allocation in getAllConfigs failed"); ! goto cleanup; ! } ! graphicsConfigs[ind]->awt_depth = pVI12p [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI12p [i], sizeof (XVisualInfo)); } for (i = 0; i < n8s; i++) {
*** 506,517 **** XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); ! graphicsConfigs [ind]->awt_depth = pVI8s [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8s [i], sizeof (XVisualInfo)); } for (i = 0; i < n8gs; i++) { --- 522,537 ---- XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs[ind] = ZALLOC (_AwtGraphicsConfigData); ! if (graphicsConfigs[ind] == NULL) { ! JNU_ThrowOutOfMemoryError(env, "allocation in getAllConfigs failed"); ! goto cleanup; ! } ! graphicsConfigs[ind]->awt_depth = pVI8s [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8s [i], sizeof (XVisualInfo)); } for (i = 0; i < n8gs; i++) {
*** 519,530 **** XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); ! graphicsConfigs [ind]->awt_depth = pVI8gs [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8gs [i], sizeof (XVisualInfo)); } for (i = 0; i < n8sg; i++) { --- 539,554 ---- XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs[ind] = ZALLOC (_AwtGraphicsConfigData); ! if (graphicsConfigs[ind] == NULL) { ! JNU_ThrowOutOfMemoryError(env, "allocation in getAllConfigs failed"); ! goto cleanup; ! } ! graphicsConfigs[ind]->awt_depth = pVI8gs [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8gs [i], sizeof (XVisualInfo)); } for (i = 0; i < n8sg; i++) {
*** 532,543 **** XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); ! graphicsConfigs [ind]->awt_depth = pVI8sg [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8sg [i], sizeof (XVisualInfo)); } for (i = 0; i < n1sg; i++) { --- 556,571 ---- XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs[ind] = ZALLOC (_AwtGraphicsConfigData); ! if (graphicsConfigs[ind] == NULL) { ! JNU_ThrowOutOfMemoryError(env, "allocation in getAllConfigs failed"); ! goto cleanup; ! } ! graphicsConfigs[ind]->awt_depth = pVI8sg [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI8sg [i], sizeof (XVisualInfo)); } for (i = 0; i < n1sg; i++) {
*** 545,560 **** XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs [ind] = ZALLOC (_AwtGraphicsConfigData); ! graphicsConfigs [ind]->awt_depth = pVI1sg [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI1sg [i], sizeof (XVisualInfo)); } if (n8p != 0) XFree (pVI8p); if (n12p != 0) XFree (pVI12p); if (n8s != 0) --- 573,596 ---- XVisualIDFromVisual(defaultConfig->awt_visInfo.visual)) { continue; } else { ind = nConfig++; } ! graphicsConfigs[ind] = ZALLOC (_AwtGraphicsConfigData); ! if (graphicsConfigs[ind] == NULL) { ! JNU_ThrowOutOfMemoryError(env, "allocation in getAllConfigs failed"); ! goto cleanup; ! } ! graphicsConfigs[ind]->awt_depth = pVI1sg [i].depth; memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVI1sg [i], sizeof (XVisualInfo)); } + screenDataPtr->numConfigs = nConfig; + screenDataPtr->configs = graphicsConfigs; + + cleanup: if (n8p != 0) XFree (pVI8p); if (n12p != 0) XFree (pVI12p); if (n8s != 0)
*** 564,576 **** if (n8sg != 0) XFree (pVI8sg); if (n1sg != 0) XFree (pVI1sg); - screenDataPtr->numConfigs = nConfig; - screenDataPtr->configs = graphicsConfigs; - AWT_UNLOCK (); } #ifndef HEADLESS --- 600,609 ----
< prev index next >