axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amant...@apache.org
Subject svn commit: r1523128 - in /axis/axis2/c/core/trunk: axiom/test/om/test_om.c guththila/src/guththila_reader.c
Date Fri, 13 Sep 2013 22:25:04 GMT
Author: amantaut
Date: Fri Sep 13 22:25:03 2013
New Revision: 1523128

URL: http://svn.apache.org/r1523128
Log:
Fix for issue AXIS2C-1628 + test.

Modified:
    axis/axis2/c/core/trunk/axiom/test/om/test_om.c
    axis/axis2/c/core/trunk/guththila/src/guththila_reader.c

Modified: axis/axis2/c/core/trunk/axiom/test/om/test_om.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/axiom/test/om/test_om.c?rev=1523128&r1=1523127&r2=1523128&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/axiom/test/om/test_om.c (original)
+++ axis/axis2/c/core/trunk/axiom/test/om/test_om.c Fri Sep 13 22:25:03 2013
@@ -87,7 +87,10 @@ test_om_build(
 
     f = fopen(filename, "r");
     if (!f)
+    {
+        printf("FILE COULDN'T BE OPENED %s \n",filename);
         return -1;
+    }
 
     /** create pull parser */
     reader =
@@ -121,7 +124,10 @@ test_om_build(
         get root element , building starts hear 
      */
     if (!document)
+    {
+        printf("COULDN'T BUILD DOCUMENT");
         return -1;
+    }
 
     node1 = axiom_document_get_root_element(document, environment);
     if (!node1)
@@ -269,6 +275,44 @@ test_om_build(
     return 0;
 }
 
+
+int test_om_buffer()
+{
+    /*AXIS2C-1628 buffer modified by axiom_node_create_from_buffer */
+    axis2_char_t * output;
+
+    char * xml = strdup("<foo>T1 &amp; T2</foo>");
+    char * xml_unaltered= strdup("<foo>T1 &amp; T2</foo>");
+
+    printf("\nstart test_om_bufer\n");
+
+    axiom_node_t * om_node = axiom_node_create_from_buffer(environment, xml);
+
+    output = axiom_node_to_string(om_node,environment);
+
+    if(axutil_strcmp(xml,xml_unaltered))
+    {
+        printf("ERROR BUFFER MODIFIED\n");
+        return -1;
+    }
+
+    if(axutil_strcmp(output,xml_unaltered))
+    {
+        printf("ERROR OUTPUT DOESNT MATCH\n");
+        return -1;
+    }
+
+    axiom_node_free_tree(om_node,environment);
+    AXIS2_FREE(environment->allocator, output);
+    AXIS2_FREE(environment->allocator, xml);
+    AXIS2_FREE(environment->allocator, xml_unaltered);
+
+    printf("\nend test_om_bufer\n");
+
+    return 0;
+}
+
+
 int
 test_om_serialize(
     )
@@ -396,6 +440,7 @@ main(
     environment = axutil_env_create_with_error_log(allocator, error, axis_log);
     test_om_build(file_name);
     test_om_serialize();
+    test_om_buffer();
 
     axutil_env_free(environment);
     return 0;

Modified: axis/axis2/c/core/trunk/guththila/src/guththila_reader.c
URL: http://svn.apache.org/viewvc/axis/axis2/c/core/trunk/guththila/src/guththila_reader.c?rev=1523128&r1=1523127&r2=1523128&view=diff
==============================================================================
--- axis/axis2/c/core/trunk/guththila/src/guththila_reader.c (original)
+++ axis/axis2/c/core/trunk/guththila/src/guththila_reader.c Fri Sep 13 22:25:03 2013
@@ -77,7 +77,7 @@ guththila_reader_create_for_memory(
     }
 
     reader->type = GUTHTHILA_MEMORY_READER;
-    reader->buff = buffer;
+    reader->buff = strdup(buffer);
     reader->buff_size = size;
     reader->fp = NULL;
     reader->input_read_callback = NULL;
@@ -115,6 +115,10 @@ guththila_reader_free(
     guththila_reader_t * r,
     const axutil_env_t * env)
 {
+    if(r->type == GUTHTHILA_MEMORY_READER && r->buff)
+    {
+    	AXIS2_FREE(env->allocator,r->buff);
+    }
     if(r->type == GUTHTHILA_FILE_READER && r->fp)
     {
         fclose(r->fp);



Mime
View raw message