Changeset 4972:4341665f3041 in roaraudio


Ignore:
Timestamp:
05/16/11 14:16:42 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

detect changes in null-buffer on several memmgr calls

Location:
libroar
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libroar/libroar.c

    r4970 r4972  
    171171 switch (error) { 
    172172  case ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD: 
    173     roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, line, file, prefix, "in %s() a guard segment memory corruption has happened. Backup your data and terminate this program. Report this lion to developer. Thanks.", func); 
     173    roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, line, file, prefix, "in %s() a guard segment memory corruption was detected. Backup your data and terminate this program. Report this lion to developer. Thanks.", func); 
    174174    return; 
    175175   break; 
     
    188188 } 
    189189 
    190  roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, line, file, prefix, "in %s() a _FATAL_ error of type \"%s\" happend. Terminating program. Report this lion to developer. Thanks.", func, errname); 
     190 roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, line, file, prefix, "in %s() a _FATAL_ error of type \"%s\" was detected. Terminating program. Report this lion to developer. Thanks.", func, errname); 
    191191 
    192192#ifdef SIGKILL 
  • libroar/memmgr.c

    r4971 r4972  
    3636#include "libroar.h" 
    3737 
    38 #ifdef ROAR_USE_MEMMGR 
    3938#define NULL_BUFFER_CONST "RoarAudio" 
    4039static char _libroar_null_buffer[] = NULL_BUFFER_CONST; // A byte sequense >= 8 byte. 
    41 #endif 
     40 
     41static inline void _libroar_null_buffer_check(void) { 
     42 if ( memcmp(_libroar_null_buffer, NULL_BUFFER_CONST, sizeof(_libroar_null_buffer)) != 0 ) 
     43  roar_panic(ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD, NULL); 
     44 memcpy(_libroar_null_buffer, NULL_BUFFER_CONST, sizeof(_libroar_null_buffer)); 
     45} 
    4246 
    4347#define _err(x) do { roar_err_set((x)); return NULL; } while (0) 
     
    4751 void * ret; 
    4852 
    49  if ( nmemb == 0 || size == 0 ) 
    50   return _libroar_null_buffer; 
     53 if ( nmemb == 0 || size == 0 ) { 
     54  _libroar_null_buffer_check(); 
     55  return _libroar_null_buffer; 
     56 } 
    5157 
    5258#ifdef ROAR_HAVE_CALLOC 
     
    7278 void * ret; 
    7379 
    74  if ( size == 0 ) 
    75   return _libroar_null_buffer; 
     80 if ( size == 0 ) { 
     81  _libroar_null_buffer_check(); 
     82  return _libroar_null_buffer; 
     83 } 
    7684 
    7785#ifdef ROAR_HAVE_MALLOC 
     
    93101 
    94102int    roar_mm_free(void *ptr) { 
    95  if ( ptr == _libroar_null_buffer ) 
     103 
     104 if ( ptr == _libroar_null_buffer ) { 
     105  _libroar_null_buffer_check(); 
    96106  return 0; 
     107 } 
    97108 
    98109#ifdef ROAR_HAVE_FREE 
     
    119130 if ( size == 0 ) { 
    120131  roar_mm_free(ptr); 
     132  _libroar_null_buffer_check(); 
    121133  return _libroar_null_buffer; 
    122134 } 
     
    142154  _err(ROAR_ERROR_FAULT); 
    143155 
     156 if ( len == 0 ) { 
     157  _libroar_null_buffer_check(); 
     158  return _libroar_null_buffer; 
     159 } 
     160 
    144161 ret = roar_mm_malloc(len); 
    145162 
     
    189206 if ( s == NULL ) 
    190207  _err(ROAR_ERROR_FAULT); 
     208 
     209 if ( n == 0 ) { 
     210  _libroar_null_buffer_check(); 
     211  return _libroar_null_buffer; 
     212 } 
    191213 
    192214#ifdef ROAR_HAVE_STRDUP 
Note: See TracChangeset for help on using the changeset viewer.