Skip to content

Commit

Permalink
Merge branch 'cmake' into cmake_win
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSJohnson committed May 11, 2024
2 parents b0ae6f9 + b3d2b54 commit 0990fd3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions contrib/champ/os_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,15 @@ void *OSMemoryMalloc(unsigned int size,const char *file,int line,int type)
rec=(DebugRec*)malloc(sizeof(DebugRec)+size);
if(!rec)
return(NULL);
strcpy(rec->file,file);

int len = strlen(file);
int max_size = sizeof(rec->file) - 1;
if (len > max_size) {
strcpy(rec->file, file + len - max_size);
} else {
strcpy(rec->file, file);
}
rec->file[max_size - 1] = '\0';
rec->line=line;
rec->size=size;
rec->type=type;
Expand All @@ -196,7 +204,15 @@ void *OSMemoryCalloc(unsigned int count,unsigned int size,const char *file,int l
rec=(DebugRec*)calloc(1,sizeof(DebugRec)+size);
if(!rec)
return(NULL);
strcpy(rec->file,file);

int len = strlen(file);
int max_size = sizeof(rec->file) - 1;
if (len > max_size) {
strcpy(rec->file, file + len - max_size);
} else {
strcpy(rec->file, file);
}
rec->file[max_size - 1] = '\0';
rec->line=line;
rec->size=size;
rec->type=type;
Expand Down

0 comments on commit 0990fd3

Please sign in to comment.