ipartola / hawkeye

An simple and fast USB webcam MJPEG streaming server.
Other
206 stars 28 forks source link

Fix segfault issue #1 #2

Closed XavierBerger closed 9 years ago

XavierBerger commented 9 years ago

dst variable is set to NULL after initialization of settings but in some circonstance, the variable is still used (log_level, format,...) and was causing the segfault.

ipartola commented 9 years ago

I don't have a setup with an actual camera handy, especially with Ubuntu 14.04, but I think I know what the problem is: we shouldn't be setting *c->dst to NULL for non-string types. Can you try it with the following patch instead:

diff --git a/src/config.c b/src/config.c
index 47762d5..9d25542 100644
--- a/src/config.c
+++ b/src/config.c
@@ -157,7 +157,9 @@ void add_config_item(struct config *con, signed char short_name, char *long_name
     c->long_option.flag = NULL;
     c->long_option.val = c->short_name;

-    *c->dst = NULL;
+    if (dst_type == CONFIG_STR) {
+        *c->dst = NULL;
+    }

     con->count++;

Let me know if this works better. Just for fun, can you try compiling it using clang instead of gcc? Just modify src/Makefile to do that.

XavierBerger commented 9 years ago

Your fix works perfectly both on Ubuntu and Raspbian. I didn't tried clang since it is not installed on my PC.

ipartola commented 9 years ago

Closing since I pushed a different bug fix earlier.