On 06/03/2011 12:00 PM, Ivana Hutarova Varekova wrote:
> fix return value check in cgget (strdup and add_record_to_buffer functions)
>
> Signed-off-by: Ivana Hutarova Varekova <[email protected]>
Merged and pushed, thanks
> ---
>
> src/tools/cgget.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/src/tools/cgget.c b/src/tools/cgget.c
> index 0411a51..81a5609 100644
> --- a/src/tools/cgget.c
> +++ b/src/tools/cgget.c
> @@ -276,7 +276,7 @@ static int display_values(char **controllers, int max,
> const char *group_name,
> return result;
> }
>
> -void add_record_to_buffer(char **buffer, char *record, int capacity)
> +int add_record_to_buffer(char **buffer, char *record, int capacity)
> {
> int i;
>
> @@ -286,8 +286,13 @@ void add_record_to_buffer(char **buffer, char *record,
> int capacity)
> break;
> }
>
> - if (i < capacity)
> + if (i < capacity) {
> buffer[i] = strdup(record);
> + if (buffer[i] == NULL)
> + return 1;
> + return 0;
> + }
> + return 1;
> }
>
>
> @@ -347,7 +352,7 @@ int main(int argc, char *argv[])
>
> case 'r':
> /* Add name to buffer. */
> - add_record_to_buffer(names, optarg, capacity);
> + ret = add_record_to_buffer(names, optarg, capacity);
> if (ret) {
> result = ret;
> goto err;
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Discover what all the cheering's about.
> Get your free trial download today.
> http://p.sf.net/sfu/quest-dev2dev2
> _______________________________________________
> Libcg-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libcg-devel
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel