aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dlfcn.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/dlfcn.c b/src/dlfcn.c
index 532af91..3251661 100644
--- a/src/dlfcn.c
+++ b/src/dlfcn.c
@@ -186,13 +186,20 @@ static void save_err_str( const char *str )
186 186
187static void save_err_ptr_str( const void *ptr ) 187static void save_err_ptr_str( const void *ptr )
188{ 188{
189 char ptr_buf[19]; /* 0x<pointer> up to 64 bits. */ 189 char ptr_buf[2 + 2 * sizeof( ptr ) + 1];
190 char num;
191 size_t i;
190 192
191#ifdef _MSC_VER 193 ptr_buf[0] = '0';
192/* Supress warning C4996: 'sprintf': This function or variable may be unsafe */ 194 ptr_buf[1] = 'x';
193#pragma warning( suppress: 4996 ) 195
194#endif 196 for( i = 0; i < 2 * sizeof( ptr ); i++ )
195 sprintf( ptr_buf, "0x%p", ptr ); 197 {
198 num = ( ( (ULONG_PTR) ptr ) >> ( 8 * sizeof( ptr ) - 4 * ( i + 1 ) ) ) & 0xF;
199 ptr_buf[2+i] = num + ( ( num < 0xA ) ? '0' : ( 'A' - 0xA ) );
200 }
201
202 ptr_buf[2 + 2 * sizeof( ptr )] = 0;
196 203
197 save_err_str( ptr_buf ); 204 save_err_str( ptr_buf );
198} 205}