Handling the NULL string value
authorSung-jae Park <nicesj.park@samsung.com>
Thu, 30 Aug 2012 07:15:22 +0000 (16:15 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Sun, 2 Sep 2012 05:07:59 +0000 (14:07 +0900)
Change-Id: I763f8b04386fdf98ff7d1a8ed4abf500ec813c65

debian/changelog
packaging/libcom-core.spec
src/packet.c

index 8d33637..90ab61d 100644 (file)
@@ -1,3 +1,10 @@
+com-core (0.2.2) unstable; urgency=low
+
+  * Git: slp/pkgs/c/com-core
+  * Tag: com-core_0.2.2
+
+ -- Sung-jae Park <nicesj.park@samsung.com>  Sun, 02 Sep 2012 14:07:48 +0900
+
 com-core (0.2.1) unstable; urgency=low
 
   * Git: slp/pkgs/c/com-core
index 5d84434..c910249 100644 (file)
@@ -1,6 +1,6 @@
 Name: libcom-core
 Summary: Library for the light-weight IPC 
-Version: 0.2.1
+Version: 0.2.2
 Release: 1
 Group: main/util
 License: Flora License
index b3787b1..ab15c32 100644 (file)
@@ -157,16 +157,29 @@ static inline struct packet *packet_body_filler(struct packet *packet, int paylo
                case 'S':
                        str = (char *)va_arg(va, char *);
 
-                       packet->data->head.payload_size += strlen(str) + 1; /*!< Including NIL */
-                       packet->data = check_and_expand_packet(packet->data, &payload_size);
-                       if (!packet->data) {
-                               packet->state = INVALID;
-                               free(packet);
-                               packet = NULL;
-                               goto out;
+                       if (str) {
+                               packet->data->head.payload_size += strlen(str) + 1; /*!< Including NIL */
+                               packet->data = check_and_expand_packet(packet->data, &payload_size);
+                               if (!packet->data) {
+                                       packet->state = INVALID;
+                                       free(packet);
+                                       packet = NULL;
+                                       goto out;
+                               }
+
+                               strcpy(payload, str); /*!< Including NIL */
+                       } else {
+                               packet->data->head.payload_size += 1;
+                               packet->data = check_and_expand_packet(packet->data, &payload_size);
+                               if (!packet->data) {
+                                       packet->state = INVALID;
+                                       free(packet);
+                                       packet = NULL;
+                                       goto out;
+                               }
+
+                               payload[0] = '\0';
                        }
-
-                       strcpy(payload, str); /*!< Including NIL */
                        break;
                case 'd':
                case 'D':