changeset 35253:48db1b241757

Try to do something sensible when malloc fails instead of continuing which is sure to crash.
author reimar
date Mon, 05 Nov 2012 20:45:40 +0000
parents a1e273544f61
children 3828cde710a2
files sub/spudec.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sub/spudec.c	Mon Nov 05 20:42:00 2012 +0000
+++ b/sub/spudec.c	Mon Nov 05 20:45:40 2012 +0000
@@ -956,6 +956,11 @@
 	  table_y = calloc(spu->scaled_height, sizeof(scale_pixel));
 	  if (!table_x || !table_y) {
 	    mp_msg(MSGT_SPUDEC, MSGL_FATAL, "Fatal: spudec_draw_scaled: calloc failed\n");
+	    free(table_x);
+	    table_x = NULL;
+	    free(table_y);
+	    table_y = NULL;
+	    break;
 	  }
 	  scale_table(0, 0, spu->width - 1, spu->scaled_width - 1, table_x);
 	  scale_table(0, 0, spu->height - 1, spu->scaled_height - 1, table_y);