source_offset + (position + appendage_size) is somehow strange. It seems that you tried to catenate the second string with a substring of the first copying the result in the first string.
source_offset + (position + appendage_size) is the suffix of the source string starting at offset position+appendage_size which is a non-sense as it is past the end of the source string...
May be you wanted something like this?
If you want to catenate the two string then the following is correct:
size_t appendage_size = strlen(appendage);
source_offset = realloc(source_offset, position + appendage_size + 1);
sprintf( &source_offset[position], "%s", appendage );
Which appends appendage to source_offset starting at position.
Now if you want to insert appendage in the middle this can be a little more tricky:
size_t appendage_size = strlen(appendage);
char *result = malloc(strlen(source_offset) + appendage_size + 1);
char cut = source_offset[position];
source_offset[position] = '\0';
sprintf( result, "%s%s%c%s", source_offset,appendage,cut,source_offset+position+1);
// do hat you want with result
Beware that realloc may change the base address of the initial memory, so you can't do things like this as the parameter value source_offset will be changed only locally.
strcat?strcatisn't included because of a mysterious reason.reallocdecides to move it elsewhere? Also, you fell into the usualx = realloc(x, n)antipattern.positionsupposed to be? Regardless of what it is, thesprintfargs seem non-sensical -- what are they trying to do?x = realloc(x, n);is fine so long as you plan to abort the process on failure. The pass-by-value error is orthogonal (it'd still occur if using the better realloc pattern)