cinera_config.c: Prevent read access crash

Passing an empty string to StripSlashes() would crash.

Also add a conditional around the ctime calls in the Won Build System,
to only run it if it exists.
This commit is contained in:
Matt Mascarenhas 2020-05-10 21:25:05 +01:00
parent 3e0ba0b77b
commit 33e590c6da
2 changed files with 22 additions and 12 deletions

View File

@ -1,10 +1,16 @@
#if 0
ctime -begin ${0%.*}.ctm
if [ $(command -v ctime 2>/dev/null) ]; then
ctime -begin ${0%.*}.ctm
fi
#gcc -g -fsanitize=address -Wall -std=c99 -pipe $0 -o ${0%.*} hmml.a -lcurl
gcc -O2 -Wall -std=c99 -pipe $0 -o ${0%.*} hmml.a -lcurl
#clang -fsanitize=address -g -Wall -std=c99 -pipe $0 -o ${0%.*} hmml.a -lcurl
#clang -O2 -Wall -std=c99 -pipe $0 -o ${0%.*} hmml.a -lcurl
ctime -end ${0%.*}.ctm
if [ $(command -v ctime 2>/dev/null) ]; then
ctime -end ${0%.*}.ctm
fi
exit
#endif
@ -17,7 +23,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 7,
.Patch = 5
.Patch = 6
};
#include <stdarg.h> // NOTE(matt): varargs
@ -10962,7 +10968,8 @@ typedef struct
void
OffsetAssociatedIndex(asset_index_and_location *AssetDeletionRecords, int AssetDeletionRecordCount, int32_t *Index)
{
fprintf(stderr, "Possibly offsetting associated index\n");
// TODO(matt): Do we really need to print this?
//fprintf(stderr, "Possibly offsetting associated index\n");
for(int i = AssetDeletionRecordCount - 1; i >= 0; --i)
{
if(*Index > AssetDeletionRecords[i].Index)

View File

@ -2908,6 +2908,8 @@ string
StripSlashes(string Path, path_relativity Relativity)
{
string Result = Path;
if(Path.Length > 0)
{
if(Relativity == P_REL)
{
while(*Result.Base == '/')
@ -2921,6 +2923,7 @@ StripSlashes(string Path, path_relativity Relativity)
{
--Result.Length;
}
}
return Result;
}