At Wed, 27 Jun 2007 16:33:52 -0400, J. Scott Merritt wrote:
Dear list,
Using SALSA-Lib 0.0.2, I call snd_pcm_open snd_pcm_hw_params_malloc snd_pcm_hw_params_any
The call to snd_pcm_hw_params_any appears to clobber memory beyond the end of the hw_params allocated by snd_pcm_hw_params_malloc (as reported by linking in -lmcheck).
Gosh, my bad. I didn't test *_malloc() at all.
There was a stupid bug in the template I copy-n-pasted. The fix patch is below. I'll release version 0.0.3 soon later.
Thanks for reporting!
Takashi
diff -r 47cb6e3fe0b7 src/ctl_macros.h --- a/src/ctl_macros.h Thu Jun 21 18:16:47 2007 +0200 +++ b/src/ctl_macros.h Thu Jun 28 12:52:16 2007 +0200 @@ -305,7 +305,7 @@ static inline static inline int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -411,7 +411,7 @@ static inline static inline int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -487,7 +487,7 @@ static inline static inline int snd_ctl_event_malloc(snd_ctl_event_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -526,7 +526,7 @@ static inline static inline int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -627,7 +627,7 @@ static inline static inline int snd_ctl_elem_info_malloc(snd_ctl_elem_info_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -912,7 +912,7 @@ static inline static inline int snd_ctl_elem_value_malloc(snd_ctl_elem_value_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; diff -r 47cb6e3fe0b7 src/hwdep_macros.h --- a/src/hwdep_macros.h Thu Jun 21 18:16:47 2007 +0200 +++ b/src/hwdep_macros.h Thu Jun 28 12:52:16 2007 +0200 @@ -107,7 +107,7 @@ static inline static inline int snd_hwdep_info_malloc(snd_hwdep_info_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -170,7 +170,7 @@ static inline static inline int snd_hwdep_dsp_status_malloc(snd_hwdep_dsp_status_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -228,7 +228,7 @@ static inline static inline int snd_hwdep_dsp_image_malloc(snd_hwdep_dsp_image_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; diff -r 47cb6e3fe0b7 src/mixer_macros.h --- a/src/mixer_macros.h Thu Jun 21 18:16:47 2007 +0200 +++ b/src/mixer_macros.h Thu Jun 28 12:52:16 2007 +0200 @@ -518,7 +518,7 @@ static inline static inline int snd_mixer_selem_id_malloc(snd_mixer_selem_id_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; diff -r 47cb6e3fe0b7 src/pcm_macros.h --- a/src/pcm_macros.h Thu Jun 21 18:16:47 2007 +0200 +++ b/src/pcm_macros.h Thu Jun 28 12:52:16 2007 +0200 @@ -599,7 +599,7 @@ static inline static inline int snd_pcm_access_mask_malloc(snd_pcm_access_mask_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -663,7 +663,7 @@ static inline static inline int snd_pcm_format_mask_malloc(snd_pcm_format_mask_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -727,7 +727,7 @@ static inline static inline int snd_pcm_subformat_mask_malloc(snd_pcm_subformat_mask_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -795,7 +795,7 @@ static inline static inline int snd_pcm_hw_params_malloc(snd_pcm_hw_params_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -1770,7 +1770,7 @@ static inline static inline int snd_pcm_sw_params_malloc(snd_pcm_sw_params_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -1940,7 +1940,7 @@ static inline static inline int snd_pcm_status_malloc(snd_pcm_status_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -2025,7 +2025,7 @@ static inline static inline int snd_pcm_info_malloc(snd_pcm_info_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; diff -r 47cb6e3fe0b7 src/rawmidi_macros.h --- a/src/rawmidi_macros.h Thu Jun 21 18:16:47 2007 +0200 +++ b/src/rawmidi_macros.h Thu Jun 28 12:52:16 2007 +0200 @@ -77,7 +77,7 @@ static inline static inline int snd_rawmidi_info_malloc(snd_rawmidi_info_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!ptr) return -ENOMEM; return 0; @@ -193,7 +193,7 @@ static inline static inline int snd_rawmidi_params_malloc(snd_rawmidi_params_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!ptr) return -ENOMEM; return 0; @@ -283,7 +283,7 @@ static inline static inline int snd_rawmidi_status_malloc(snd_rawmidi_status_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!ptr) return -ENOMEM; return 0; diff -r 47cb6e3fe0b7 src/timer_macros.h --- a/src/timer_macros.h Thu Jun 21 18:16:47 2007 +0200 +++ b/src/timer_macros.h Thu Jun 28 12:52:16 2007 +0200 @@ -124,7 +124,7 @@ static inline static inline int snd_timer_id_malloc(snd_timer_id_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -211,7 +211,7 @@ static inline static inline int snd_timer_ginfo_malloc(snd_timer_ginfo_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -299,7 +299,7 @@ static inline static inline int snd_timer_info_malloc(snd_timer_info_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -356,7 +356,7 @@ static inline static inline int snd_timer_params_malloc(snd_timer_params_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0; @@ -472,7 +472,7 @@ static inline static inline int snd_timer_status_malloc(snd_timer_status_t **ptr) { - *ptr = calloc(1, sizeof(*ptr)); + *ptr = calloc(1, sizeof(**ptr)); if (!*ptr) return -ENOMEM; return 0;