Update acquire/release pixmap operation & fix crash bug
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 3 Jul 2013 11:26:49 +0000 (20:26 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 3 Jul 2013 11:26:49 +0000 (20:26 +0900)
while terminating service threads,

in case of the "ptr" is not initialized (at the first time),
calling a "free" function can be crashed.

Change-Id: If261e1ab4f35ac72d64ccb9dcba127e1cdc8e083

include/fb.h
packaging/data-provider-master.spec
src/fb.c
src/server.c
src/service_common.c

index bf6d224..0061bc6 100644 (file)
@@ -16,6 +16,7 @@
 
 struct fb_info;
 struct inst_info;
+struct buffer_info;
 
 extern int fb_init(void);
 extern int fb_fini(void);
@@ -34,5 +35,5 @@ extern int fb_resize(struct fb_info *info, int w, int h);
  */
 extern void *fb_pixmap_render_pre(struct fb_info *info);
 extern int fb_pixmap_render_post(struct fb_info *info);
-
+extern struct buffer_info *fb_buffer_info(struct fb_info *info);
 /* End of a file */
index fd1283f..a442560 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.24.15
+Version: 0.24.16
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index 1056dc5..d4db09f 100644 (file)
--- a/src/fb.c
+++ b/src/fb.c
@@ -276,4 +276,9 @@ HAPI int fb_pixmap_render_post(struct fb_info *info)
        return buffer_handler_pixmap_release_buffer(canvas);
 }
 
+HAPI struct buffer_info *fb_buffer_info(struct fb_info *info)
+{
+       return info->buffer;
+}
+
 /* End of a file */
index 5725aac..1934462 100644 (file)
@@ -4331,8 +4331,26 @@ static struct packet *client_lb_acquire_pixmap(pid_t pid, int handle, const stru
 
        buffer = instance_lb_buffer(inst);
        if (!buffer) {
-               ErrPrint("Unable to get LB buffer: %s\n", id);
-               goto out;
+               struct script_info *script_info;
+               struct fb_info *fb_info;
+
+               script_info = instance_lb_script(inst);
+               if (!script_info) {
+                       ErrPrint("Unable to get LB buffer: %s\n", id);
+                       goto out;
+               }
+
+               fb_info = script_handler_fb(script_info);
+               if (!fb_info) {
+                       ErrPrint("Unable to get fb_info: %s\n", id);
+                       goto out;
+               }
+
+               buffer = fb_buffer_info(fb_info);
+               if (!buffer) {
+                       ErrPrint("Unable to get buffer_info: %s\n", id);
+                       goto out;
+               }
        }
 
        buf_ptr = buffer_handler_pixmap_ref(buffer);
@@ -4427,8 +4445,26 @@ static struct packet *client_pd_acquire_pixmap(pid_t pid, int handle, const stru
 
        buffer = instance_pd_buffer(inst);
        if (!buffer) {
-               ErrPrint("Unable to get PD buffer (%s)\n", id);
-               goto out;
+               struct script_info *script_info;
+               struct fb_info *fb_info;
+
+               script_info = instance_pd_script(inst);
+               if (!script_info) {
+                       ErrPrint("Unable to get LB buffer: %s\n", id);
+                       goto out;
+               }
+
+               fb_info = script_handler_fb(script_info);
+               if (!fb_info) {
+                       ErrPrint("Unable to get fb_info: %s\n", id);
+                       goto out;
+               }
+
+               buffer = fb_buffer_info(fb_info);
+               if (!buffer) {
+                       ErrPrint("Unable to get buffer_info: %s\n", id);
+                       goto out;
+               }
        }
 
        buf_ptr = buffer_handler_pixmap_ref(buffer);
index 1895d8c..b9116a4 100644 (file)
@@ -104,7 +104,7 @@ static void *client_packet_pump_main(void *data)
        struct service_context *svc_ctx = tcb->svc_ctx;
        struct packet *packet;
        fd_set set;
-       char *ptr;
+       char *ptr = NULL;
        int size;
        int packet_offset;
        int recv_offset;