fix return value check in cgget (strdup and add_record_to_buffer functions)

Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com>
---

 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;


------------------------------------------------------------------------------
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
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to