mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-31 11:19:18 -05:00
Add security checks on file writting
This commit is contained in:
@ -910,6 +910,8 @@ void ExportWaveAsCode(Wave wave, const char *fileName)
|
|||||||
|
|
||||||
FILE *txtFile = fopen(fileName, "wt");
|
FILE *txtFile = fopen(fileName, "wt");
|
||||||
|
|
||||||
|
if (txtFile != NULL)
|
||||||
|
{
|
||||||
fprintf(txtFile, "\n//////////////////////////////////////////////////////////////////////////////////\n");
|
fprintf(txtFile, "\n//////////////////////////////////////////////////////////////////////////////////\n");
|
||||||
fprintf(txtFile, "// //\n");
|
fprintf(txtFile, "// //\n");
|
||||||
fprintf(txtFile, "// WaveAsCode exporter v1.0 - Wave data exported as an array of bytes //\n");
|
fprintf(txtFile, "// WaveAsCode exporter v1.0 - Wave data exported as an array of bytes //\n");
|
||||||
@ -942,6 +944,7 @@ void ExportWaveAsCode(Wave wave, const char *fileName)
|
|||||||
|
|
||||||
fclose(txtFile);
|
fclose(txtFile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Play a sound
|
// Play a sound
|
||||||
void PlaySound(Sound sound)
|
void PlaySound(Sound sound)
|
||||||
|
|||||||
@ -849,12 +849,13 @@ void ExportImageAsCode(Image image, const char *fileName)
|
|||||||
{
|
{
|
||||||
#define BYTES_TEXT_PER_LINE 20
|
#define BYTES_TEXT_PER_LINE 20
|
||||||
|
|
||||||
|
FILE *txtFile = fopen(fileName, "wt");
|
||||||
|
|
||||||
|
if (txtFile != NULL)
|
||||||
|
{
|
||||||
char varFileName[256] = { 0 };
|
char varFileName[256] = { 0 };
|
||||||
int dataSize = GetPixelDataSize(image.width, image.height, image.format);
|
int dataSize = GetPixelDataSize(image.width, image.height, image.format);
|
||||||
|
|
||||||
FILE *txtFile = fopen(fileName, "wt");
|
|
||||||
|
|
||||||
fprintf(txtFile, "\n");
|
|
||||||
fprintf(txtFile, "////////////////////////////////////////////////////////////////////////////////////////\n");
|
fprintf(txtFile, "////////////////////////////////////////////////////////////////////////////////////////\n");
|
||||||
fprintf(txtFile, "// //\n");
|
fprintf(txtFile, "// //\n");
|
||||||
fprintf(txtFile, "// ImageAsCode exporter v1.0 - Image pixel data exported as an array of bytes //\n");
|
fprintf(txtFile, "// ImageAsCode exporter v1.0 - Image pixel data exported as an array of bytes //\n");
|
||||||
@ -882,6 +883,7 @@ void ExportImageAsCode(Image image, const char *fileName)
|
|||||||
|
|
||||||
fclose(txtFile);
|
fclose(txtFile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Copy an image to a new image
|
// Copy an image to a new image
|
||||||
Image ImageCopy(Image image)
|
Image ImageCopy(Image image)
|
||||||
|
|||||||
Reference in New Issue
Block a user