diff --git a/lagueirtofile b/lagueirtofile index dfd7853..6422a3b 100644 --- a/lagueirtofile +++ b/lagueirtofile @@ -12,6 +12,13 @@ executable = mini_debug sourcepath = source+ buildpath = build +[linux_sanitize] default +cppflags = -D LUA_USE_LINUX -D DEBUG -g -Wall -std=c++20 -fsanitize=address -fno-omit-frame-pointer -Isource +libs = -fsanitize=address -lSDL3 -lGL +executable = mini_san +sourcepath = source+ +buildpath = build + [windows] cppflags = -Wall -Os -ffunction-sections -fdata-sections -std=c++20 -Isource libs = icon.res -Wl,--gc-sections -lmingw32 -lSDL3 -lopengl32 -static-libstdc++ -static-libgcc -lpthread -mwindows diff --git a/source/backends/SDL3/input.cpp b/source/backends/SDL3/input.cpp index fa65321..4794a24 100644 --- a/source/backends/SDL3/input.cpp +++ b/source/backends/SDL3/input.cpp @@ -126,6 +126,7 @@ namespace backend } } } + SDL_free(joysticks); } } diff --git a/source/mini/file/file.cpp b/source/mini/file/file.cpp index e4fcb90..df318b8 100644 --- a/source/mini/file/file.cpp +++ b/source/mini/file/file.cpp @@ -139,7 +139,7 @@ namespace mini char *getfilebuffer(const char *resourcename, int& filesize, const bool zero_terminate) { FILE *f = getfilepointer(resourcename, filesize, true); - char* buffer = (char*)malloc(zero_terminate?filesize:filesize+1); + char* buffer = (char*)malloc(zero_terminate?filesize+1:filesize); fread(buffer, filesize, 1, f); if (zero_terminate) buffer[filesize]=0; fclose(f); @@ -158,7 +158,7 @@ namespace mini char *getfilebufferex(const char *filename, int& filesize, const bool zero_terminate) { FILE *f = getfilepointerex(filename, filesize, true); - char* buffer = (char*)malloc(zero_terminate?filesize:filesize+1); + char* buffer = (char*)malloc(zero_terminate?filesize+1:filesize); fread(buffer, filesize, 1, f); if (zero_terminate) buffer[filesize]=0; fclose(f); diff --git a/source/mini/font/font.cpp b/source/mini/font/font.cpp index b99c131..fa13e07 100644 --- a/source/mini/font/font.cpp +++ b/source/mini/font/font.cpp @@ -86,7 +86,7 @@ namespace mini // Carregar l'arxiu de disc int size; char *buffer; - buffer = file::getfilebuffer(filename, size); + buffer = file::getfilebuffer(filename, size, true); // Si no s'ha pogut, petar if (!buffer) { diff --git a/source/mini/version.h b/source/mini/version.h index 8883c09..128254b 100644 --- a/source/mini/version.h +++ b/source/mini/version.h @@ -1,3 +1,3 @@ #pragma once -#define MINI_VERSION "1.6.0" +#define MINI_VERSION "1.6.1" diff --git a/source/other/gif.h b/source/other/gif.h index 0684bab..939fd12 100644 --- a/source/other/gif.h +++ b/source/other/gif.h @@ -5,6 +5,7 @@ #include #define READ(dst, size) memcpy(dst, buffer, size); buffer += size +#define SKIP(size) buffer += size struct rgb { uint8_t r, g, b; }; @@ -116,6 +117,7 @@ void uncompress( int code_length, const uint8_t *input, int input_length, uint8_ } out += match_len; } + free(dictionary); } static int read_sub_blocks( uint8_t* buffer, uint8_t **data ) @@ -137,7 +139,7 @@ static int read_sub_blocks( uint8_t* buffer, uint8_t **data ) return data_length; } -uint8_t* process_image_descriptor( uint8_t* buffer, rgb *gct, int gct_size, int resolution_bits ) +uint8_t* process_image_descriptor( uint8_t* buffer) { image_descriptor_t image_descriptor; READ(&image_descriptor, 9); @@ -180,21 +182,15 @@ uint32_t* LoadPalette(uint8_t *buffer, uint16_t *size = NULL ) static uint8_t* LoadGif(uint8_t *buffer, uint16_t* w, uint16_t* h) { - int global_color_table_size = 0; // number of entries in global_color_table - rgb *global_color_table = NULL; - buffer += 6; // Ignore header *w = *((uint16_t*)buffer); buffer+=2; *h = *((uint16_t*)buffer); buffer+=2; const uint8_t fields = *buffer; buffer+=3; - const int color_resolution_bits = ( ( fields & 0x70 ) >> 4 ) + 1; - if ( fields & 0x80 ) { - global_color_table_size = 1 << ( ( ( fields & 0x07 ) + 1 ) ); - global_color_table = (rgb*)malloc( 3 * global_color_table_size ); - READ(global_color_table, 3 * global_color_table_size); + int global_color_table_size = 1 << ( ( ( fields & 0x07 ) + 1 ) ); + SKIP(global_color_table_size*3); } uint8_t block_type = 0x0; @@ -206,7 +202,7 @@ static uint8_t* LoadGif(uint8_t *buffer, uint16_t* w, uint16_t* h) switch ( block_type ) { case 0x2C: - return process_image_descriptor(buffer, global_color_table, global_color_table_size, color_resolution_bits); + return process_image_descriptor(buffer); case 0x21: buffer++; //size = *(buffer++); buffer += size; do { size = *(buffer++); buffer += size; } while (size != 0);