From d882e0362abb95f8becc2383a289764faad82b19 Mon Sep 17 00:00:00 2001 From: julianb0 Date: Thu, 20 Jun 2019 12:58:24 +0200 Subject: [PATCH] checks --- ka/ABI | 4 ++-- vm/cn/console.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ka/ABI b/ka/ABI index 15a730c..2a4d9ef 100644 --- a/ka/ABI +++ b/ka/ABI @@ -109,8 +109,8 @@ To the variadic function, argN can be accessed the following way: mov reg, [rbp + N*8 + 16] For instance: - mov rax, [rbp + 16] ; arg1 - mov rdx, [rbp + 24] ; arg2 + mov rax, [rbp + 16] ; arg0 + mov rdx, [rbp + 24] ; arg1 It is recommended to use the reg+reg*imm16+imm16 memory format: mov rax, [rbp + rcx * 8 + 16] ; accesses arg#rcx diff --git a/vm/cn/console.c b/vm/cn/console.c index 363a80e..2181ffd 100644 --- a/vm/cn/console.c +++ b/vm/cn/console.c @@ -114,6 +114,12 @@ void console_putat(ctx_t *ctx, char ch, int x, int y) surf = TTF_RenderText_Solid(scr_font, scr_lines[y], scr_text_color); + if (!surf) + { + logerr("console_putat: couldn't render TTF font\n"); + die(-1); + } + if (scr_texts[y]) { if (scr_rects[y]) @@ -128,10 +134,18 @@ void console_putat(ctx_t *ctx, char ch, int x, int y) scr_texts[y] = SDL_CreateTextureFromSurface(scr_rend, surf); scr_rects[y] = malloc(sizeof(SDL_Rect)); + if (scr_texts[y] == NULL) + { + logerr("console_putat: couldn't create texture from surface\n"); + SDL_FreeSurface(surf); + die(-1); + } + if (scr_rects[y] == NULL) { logerr("console_putat: not enough memory\n"); SDL_FreeSurface(surf); + SDL_DestroyTexture(scr_texts[y]); die(-1); }