VAX systems with graphics: Properly cleanup on memory allocation errors.

This commit is contained in:
Mark Pizzolato 2021-08-28 18:31:35 -07:00
parent 4c64878f7c
commit eadf12699b
5 changed files with 6 additions and 0 deletions

View file

@ -1297,6 +1297,7 @@ if (!vid_active) {
va_lines = (uint32 *) calloc (VA_XSIZE * VA_YSIZE, sizeof (uint32)); va_lines = (uint32 *) calloc (VA_XSIZE * VA_YSIZE, sizeof (uint32));
if (va_lines == NULL) { if (va_lines == NULL) {
free (va_buf); free (va_buf);
va_buf = NULL;
vid_close (); vid_close ();
return SCPE_MEM; return SCPE_MEM;
} }

View file

@ -509,6 +509,7 @@ if (!vid_active && !vc_active) {
vc_lines = (uint32 *) calloc (VC_XSIZE * VC_YSIZE, sizeof (uint32)); vc_lines = (uint32 *) calloc (VC_XSIZE * VC_YSIZE, sizeof (uint32));
if (vc_lines == NULL) { if (vc_lines == NULL) {
free (vc_buf); free (vc_buf);
vc_buf = NULL;
vid_close (); vid_close ();
return SCPE_MEM; return SCPE_MEM;
} }

View file

@ -1460,6 +1460,7 @@ if (!vid_active && !ve_active) {
ve_lines = (uint32 *) calloc (VE_XSIZE*VE_YSIZE, sizeof (uint32)); ve_lines = (uint32 *) calloc (VE_XSIZE*VE_YSIZE, sizeof (uint32));
if (ve_lines == NULL) { if (ve_lines == NULL) {
free (ve_buf); free (ve_buf);
ve_buf = NULL;
vid_close (); vid_close ();
return SCPE_MEM; return SCPE_MEM;
} }

View file

@ -1119,6 +1119,7 @@ if (!vid_active) {
va_lines = (uint32 *) calloc (VA_XSIZE * VA_YSIZE, sizeof (uint32)); va_lines = (uint32 *) calloc (VA_XSIZE * VA_YSIZE, sizeof (uint32));
if (va_lines == NULL) { if (va_lines == NULL) {
free (va_buf); free (va_buf);
va_buf = NULL;
vid_close (); vid_close ();
return SCPE_MEM; return SCPE_MEM;
} }

View file

@ -1035,6 +1035,7 @@ if (!vid_active) {
vc_lines = (uint32 *) calloc (VC_XSIZE*VC_YSIZE, sizeof (uint32)); vc_lines = (uint32 *) calloc (VC_XSIZE*VC_YSIZE, sizeof (uint32));
if (vc_lines == NULL) { if (vc_lines == NULL) {
free (vc_buf); free (vc_buf);
vc_buf = NULL;
vid_close (); vid_close ();
return SCPE_MEM; return SCPE_MEM;
} }
@ -1043,6 +1044,7 @@ if (!vid_active) {
free (vc_lines); free (vc_lines);
vc_lines = NULL; vc_lines = NULL;
free (vc_buf); free (vc_buf);
vc_buf = NULL;
vid_close (); vid_close ();
return SCPE_MEM; return SCPE_MEM;
} }