R
Ron
#define MAX_SIZE 512
char mybuffer[MAX_SIZE+1];
void myfunction( const char* src )
{
if( src == null ) { return; }
/* A core dump is occuring here */
strncpy( mybuffer, src, MAX_SIZE );
mybuffer[ MAX_SIZE ] = 0;
}
A core dump is occuring on line 10. If src is not null when I call
strncpy, is there anything about its contents that could cause strncpy
to fail? My guess is that there is no way the contents of src could
cause the core, so the pointer itself is bad, even if it is not null.
However, inspecting the calling code, src looks fine. The only thing
I can't inspect (easily) is the contents of src. I can't think of any
way the contents can be the root cause, but maybe someone reading this
knows better.
char mybuffer[MAX_SIZE+1];
void myfunction( const char* src )
{
if( src == null ) { return; }
/* A core dump is occuring here */
strncpy( mybuffer, src, MAX_SIZE );
mybuffer[ MAX_SIZE ] = 0;
}
A core dump is occuring on line 10. If src is not null when I call
strncpy, is there anything about its contents that could cause strncpy
to fail? My guess is that there is no way the contents of src could
cause the core, so the pointer itself is bad, even if it is not null.
However, inspecting the calling code, src looks fine. The only thing
I can't inspect (easily) is the contents of src. I can't think of any
way the contents can be the root cause, but maybe someone reading this
knows better.