From: <svn...@op...> - 2009-04-28 09:02:26
|
Author: bellmich Date: Tue Apr 28 11:02:10 2009 New Revision: 1071 URL: http://libsyncml.opensync.org/changeset/1071 Log: committed patch from ticket #232 (supplied by Kwan hong Lee) Modified: trunk/libsyncml/data_sync_api/data_sync.c Modified: trunk/libsyncml/data_sync_api/data_sync.c ============================================================================== --- trunk/libsyncml/data_sync_api/data_sync.c Mon Apr 27 11:52:35 2009 (r1070) +++ trunk/libsyncml/data_sync_api/data_sync.c Tue Apr 28 11:02:10 2009 (r1071) @@ -625,35 +625,40 @@ SmlDataSyncDatastore *datastore = change->datastore; /* copy data */ - smlAssert(datastore->contentType); - smlAssert(index(datastore->contentType, '/')); - size_t appClassLength = ((size_t) index(datastore->contentType, '/')) - - ((size_t) datastore->contentType); - if ( ( strstr(datastore->contentType, SML_CONTENT_TYPE_APPLICATION) == datastore->contentType && - appClassLength == strlen(SML_CONTENT_TYPE_APPLICATION) ) || - ( strstr(datastore->contentType, SML_CONTENT_TYPE_AUDIO) == datastore->contentType && - appClassLength == strlen(SML_CONTENT_TYPE_AUDIO) ) || - ( strstr(datastore->contentType, SML_CONTENT_TYPE_IMAGE) == datastore->contentType && - appClassLength == strlen(SML_CONTENT_TYPE_IMAGE) ) || - ( strstr(datastore->contentType, SML_CONTENT_TYPE_MESSAGE) == datastore->contentType && - appClassLength == strlen(SML_CONTENT_TYPE_MESSAGE) ) || - ( strstr(datastore->contentType, SML_CONTENT_TYPE_VIDEO) == datastore->contentType && - appClassLength == strlen(SML_CONTENT_TYPE_AUDIO) ) ) - { - /* binary data must be base64 encoded */ - change->data = g_base64_encode((const unsigned char *) data, size); - if (!change->data) { - smlErrorSet(error, SML_ERROR_GENERIC, - "The base 64 encoding of glib failed."); - goto error; + if (data) { + smlAssert(datastore->contentType); + smlAssert(index(datastore->contentType, '/')); + size_t appClassLength = ((size_t) index(datastore->contentType, '/')) - + ((size_t) datastore->contentType); + if ( ( strstr(datastore->contentType, SML_CONTENT_TYPE_APPLICATION) == datastore->contentType && + appClassLength == strlen(SML_CONTENT_TYPE_APPLICATION) ) || + ( strstr(datastore->contentType, SML_CONTENT_TYPE_AUDIO) == datastore->contentType && + appClassLength == strlen(SML_CONTENT_TYPE_AUDIO) ) || + ( strstr(datastore->contentType, SML_CONTENT_TYPE_IMAGE) == datastore->contentType && + appClassLength == strlen(SML_CONTENT_TYPE_IMAGE) ) || + ( strstr(datastore->contentType, SML_CONTENT_TYPE_MESSAGE) == datastore->contentType && + appClassLength == strlen(SML_CONTENT_TYPE_MESSAGE) ) || + ( strstr(datastore->contentType, SML_CONTENT_TYPE_VIDEO) == datastore->contentType && + appClassLength == strlen(SML_CONTENT_TYPE_AUDIO) ) ) + { + /* binary data must be base64 encoded */ + change->data = g_base64_encode((const unsigned char *) data, size); + if (!change->data) { + smlErrorSet(error, SML_ERROR_GENERIC, + "The base 64 encoding of glib failed."); + goto error; + } + change->size = strlen(change->data); + } else { + change->data = smlTryMalloc0(size+1, error); + if (!change->data) + goto error; + memcpy(change->data, data, size); + change->size = size; } - change->size = strlen(change->data); } else { - change->data = smlTryMalloc0(size+1, error); - if (!change->data) - goto error; - memcpy(change->data, data, size); - change->size = size; + change->data = NULL; + change->size = 0; } /* append change to datastore */ |