mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 11:43:00 +00:00
Fix assertion bugs.
This commit is contained in:
parent
c272ba56ad
commit
0724ab2ca1
19
driver.c
19
driver.c
@ -21,7 +21,6 @@
|
||||
#include "file.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include "posix_string.h"
|
||||
|
||||
@ -288,13 +287,11 @@ void init_audio(void)
|
||||
size_t max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2;
|
||||
|
||||
// Used for recording even if audio isn't enabled.
|
||||
g_extern.audio_data.conv_outsamples = (int16_t*)malloc(max_bufsamples * sizeof(int16_t) * AUDIO_MAX_RATIO);
|
||||
assert(g_extern.audio_data.conv_outsamples);
|
||||
ssnes_assert((g_extern.audio_data.conv_outsamples = (int16_t*)malloc(max_bufsamples * sizeof(int16_t) * AUDIO_MAX_RATIO)));
|
||||
g_extern.audio_data.chunk_size = g_extern.audio_data.block_chunk_size;
|
||||
|
||||
// Needs to be able to hold full content of a full max_bufsamples in addition to its own.
|
||||
g_extern.audio_data.rewind_buf = (int16_t*)malloc(max_bufsamples * sizeof(int16_t));
|
||||
assert(g_extern.audio_data.rewind_buf);
|
||||
ssnes_assert((g_extern.audio_data.rewind_buf = (int16_t*)malloc(max_bufsamples * sizeof(int16_t))));
|
||||
g_extern.audio_data.rewind_size = max_bufsamples;
|
||||
|
||||
if (!g_settings.audio.enable)
|
||||
@ -328,13 +325,11 @@ void init_audio(void)
|
||||
if (!g_extern.audio_data.source)
|
||||
g_extern.audio_active = false;
|
||||
|
||||
g_extern.audio_data.data = (float*)malloc(max_bufsamples * sizeof(float));
|
||||
assert(g_extern.audio_data.data);
|
||||
ssnes_assert((g_extern.audio_data.data = (float*)malloc(max_bufsamples * sizeof(float))));
|
||||
g_extern.audio_data.data_ptr = 0;
|
||||
|
||||
assert(g_settings.audio.out_rate < g_settings.audio.in_rate * AUDIO_MAX_RATIO);
|
||||
g_extern.audio_data.outsamples = (float*)malloc(max_bufsamples * sizeof(float) * AUDIO_MAX_RATIO);
|
||||
assert(g_extern.audio_data.outsamples);
|
||||
ssnes_assert(g_settings.audio.out_rate < g_settings.audio.in_rate * AUDIO_MAX_RATIO);
|
||||
ssnes_assert((g_extern.audio_data.outsamples = (float*)malloc(max_bufsamples * sizeof(float) * AUDIO_MAX_RATIO)));
|
||||
|
||||
g_extern.audio_data.src_ratio =
|
||||
(double)g_settings.audio.out_rate / g_settings.audio.in_rate;
|
||||
@ -416,10 +411,10 @@ static void init_filter(void)
|
||||
|
||||
g_extern.filter.buffer = (uint32_t*)malloc(SSNES_SCALE_BASE * SSNES_SCALE_BASE * g_extern.filter.scale * g_extern.filter.scale * sizeof(uint32_t));
|
||||
g_extern.filter.pitch = SSNES_SCALE_BASE * g_extern.filter.scale * sizeof(uint32_t);
|
||||
assert(g_extern.filter.buffer);
|
||||
ssnes_assert(g_extern.filter.buffer);
|
||||
|
||||
g_extern.filter.colormap = (uint32_t*)malloc(32768 * sizeof(uint32_t));
|
||||
assert(g_extern.filter.colormap);
|
||||
ssnes_assert(g_extern.filter.colormap);
|
||||
|
||||
// Set up conversion map from 16-bit XRGB1555 to 32-bit ARGB.
|
||||
for (int i = 0; i < 32768; i++)
|
||||
|
18
file.c
18
file.c
@ -21,7 +21,6 @@
|
||||
#include "boolean.h"
|
||||
#include "libsnes.hpp"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include "dynamic.h"
|
||||
#include "movie.h"
|
||||
@ -986,23 +985,24 @@ bool path_file_exists(const char *path)
|
||||
void fill_pathname(char *out_path, const char *in_path, const char *replace, size_t size)
|
||||
{
|
||||
char tmp_path[MAXPATHLEN];
|
||||
assert(strlcpy(tmp_path, in_path, sizeof(tmp_path)) < sizeof(tmp_path));
|
||||
|
||||
ssnes_assert(strlcpy(tmp_path, in_path, sizeof(tmp_path)) < sizeof(tmp_path));
|
||||
char *tok = strrchr(tmp_path, '.');
|
||||
if (tok != NULL)
|
||||
*tok = '\0';
|
||||
assert(strlcpy(out_path, tmp_path, size) < size);
|
||||
assert(strlcat(out_path, replace, size) < size);
|
||||
ssnes_assert(strlcpy(out_path, tmp_path, size) < size);
|
||||
ssnes_assert(strlcat(out_path, replace, size) < size);
|
||||
}
|
||||
|
||||
void fill_pathname_noext(char *out_path, const char *in_path, const char *replace, size_t size)
|
||||
{
|
||||
assert(strlcpy(out_path, in_path, size) < size);
|
||||
assert(strlcat(out_path, replace, size) < size);
|
||||
ssnes_assert(strlcpy(out_path, in_path, size) < size);
|
||||
ssnes_assert(strlcat(out_path, replace, size) < size);
|
||||
}
|
||||
|
||||
void fill_pathname_dir(char *in_dir, const char *in_basename, const char *replace, size_t size)
|
||||
{
|
||||
assert(strlcat(in_dir, "/", size) < size);
|
||||
ssnes_assert(strlcat(in_dir, "/", size) < size);
|
||||
|
||||
const char *base = strrchr(in_basename, '/');
|
||||
if (!base)
|
||||
@ -1013,6 +1013,6 @@ void fill_pathname_dir(char *in_dir, const char *in_basename, const char *replac
|
||||
else
|
||||
base = in_basename;
|
||||
|
||||
assert(strlcat(in_dir, base, size) < size);
|
||||
assert(strlcat(in_dir, replace, size) < size);
|
||||
ssnes_assert(strlcat(in_dir, base, size) < size);
|
||||
ssnes_assert(strlcat(in_dir, replace, size) < size);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user