2010-04-06 07:01:08 -07:00
|
|
|
#include <assert.h>
|
2010-04-01 07:22:45 -07:00
|
|
|
#include "private.h"
|
|
|
|
|
|
|
|
typedef struct _Elm_Params_Photocam
|
|
|
|
{
|
2010-10-21 15:03:43 -07:00
|
|
|
Elm_Params base;
|
2010-04-01 07:22:45 -07:00
|
|
|
const char *file;
|
|
|
|
double zoom;
|
|
|
|
const char *zoom_mode;
|
|
|
|
Eina_Bool paused:1;
|
|
|
|
Eina_Bool paused_exists:1;
|
|
|
|
Eina_Bool zoom_exists:1;
|
|
|
|
} Elm_Params_Photocam;
|
|
|
|
|
2014-01-23 03:08:10 -08:00
|
|
|
static const char* choices[] = { "manual", "auto fit", "auto fill", NULL };
|
2010-04-01 07:22:45 -07:00
|
|
|
|
|
|
|
static Elm_Photocam_Zoom_Mode
|
|
|
|
_zoom_mode_setting_get(const char *zoom_mode_str)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2010-04-07 14:30:54 -07:00
|
|
|
assert(sizeof(choices)/sizeof(choices[0]) == ELM_PHOTOCAM_ZOOM_MODE_LAST + 1);
|
2010-04-06 07:01:08 -07:00
|
|
|
|
elementary - fixed some logic errors patched by rajeev.r@samsung.com
Hi all,
I found few memory related issues in elementary package when performed static analysis on it.
These issues include:
Array indices getting out of bounds, freed memory address being passed to a function as parameter, memory not getting cleaned up because of earlier return statement.
Issues details:
1. In elm_widget.c inside function elm_widget_signal_callback_del(), it is possible that freed memory address esd is passed to the sd->callback_del_func(). I think it should be data, not esd.
Moreover what if the callback frees memory for data, then the other problem is that the return value is data from the function elm_widget_signal_callback_del() which in my opinion can be a problem.
2. Inside directory src/edje_externals for files elm_genlist.c, elm_notify.c, elm_list.c, elm_thumb.c and elm_map.c, array indices can go beyound bounary.
sizeof() operator for an array of character pointers will return [number of elements in the array * size of (char*)], basically 4 times the number of elements which has been taken care in assertion inside src/edje_extenarnals
while performing assertion but has been missed in the next statement in the loop condition.
3. In file src/lib/elm_config.c inside function _elm_config_profiles_list, freeing of file iterator has been missed out.
Please review the attached patch and let me know your opinion.
Thanks.
Regards,
Rajeev
SVN revision: 63550
2011-09-22 17:02:13 -07:00
|
|
|
for (i = 0; i < ELM_PHOTOCAM_ZOOM_MODE_LAST; i++)
|
2010-04-01 07:22:45 -07:00
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (!strcmp(zoom_mode_str, choices[i]))
|
|
|
|
return i;
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
2010-04-06 07:01:08 -07:00
|
|
|
return ELM_PHOTOCAM_ZOOM_MODE_LAST;
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-23 03:08:10 -08:00
|
|
|
external_photocam_state_set(void *data EINA_UNUSED, Evas_Object *obj,
|
|
|
|
const void *from_params, const void *to_params,
|
|
|
|
float pos EINA_UNUSED)
|
2010-04-01 07:22:45 -07:00
|
|
|
{
|
|
|
|
const Elm_Params_Photocam *p;
|
|
|
|
|
|
|
|
if (to_params) p = to_params;
|
|
|
|
else if (from_params) p = from_params;
|
|
|
|
else return;
|
|
|
|
|
|
|
|
if (p->file)
|
|
|
|
elm_photocam_file_set(obj, p->file);
|
|
|
|
if (p->zoom_exists)
|
|
|
|
elm_photocam_zoom_set(obj, p->zoom);
|
|
|
|
if (p->zoom_mode)
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
Elm_Photocam_Zoom_Mode set = _zoom_mode_setting_get(p->zoom_mode);
|
|
|
|
if (set == ELM_PHOTOCAM_ZOOM_MODE_LAST) return;
|
|
|
|
elm_photocam_zoom_mode_set(obj, set);
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
if (p->paused_exists)
|
|
|
|
elm_photocam_paused_set(obj, p->paused);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-01-23 03:08:10 -08:00
|
|
|
external_photocam_param_set(void *data EINA_UNUSED, Evas_Object *obj,
|
|
|
|
const Edje_External_Param *param)
|
2010-04-01 07:22:45 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(param->name, "file"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
elm_photocam_file_set(obj, param->s);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "zoom"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
|
|
|
|
{
|
|
|
|
elm_photocam_zoom_set(obj, param->d);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "zoom mode"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
Elm_Photocam_Zoom_Mode set = _zoom_mode_setting_get(param->s);
|
|
|
|
if (set == ELM_PHOTOCAM_ZOOM_MODE_LAST) return EINA_FALSE;
|
|
|
|
elm_photocam_zoom_mode_set(obj, set);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "paused"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
elm_photocam_paused_set(obj, param->i);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-01-23 03:08:10 -08:00
|
|
|
external_photocam_param_get(void *data EINA_UNUSED, const Evas_Object *obj,
|
|
|
|
Edje_External_Param *param)
|
2010-04-01 07:22:45 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(param->name, "file"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
param->s = elm_photocam_file_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "zoom"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
|
|
|
|
{
|
|
|
|
param->d = elm_photocam_zoom_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "zoom mode"))
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
Elm_Photocam_Zoom_Mode zoom_mode_set =
|
|
|
|
elm_photocam_zoom_mode_get(obj);
|
2010-04-06 07:01:08 -07:00
|
|
|
|
2014-01-23 03:08:10 -08:00
|
|
|
if (zoom_mode_set == ELM_PHOTOCAM_ZOOM_MODE_LAST)
|
|
|
|
return EINA_FALSE;
|
2010-04-06 07:01:08 -07:00
|
|
|
|
2014-01-23 03:08:10 -08:00
|
|
|
param->s = choices[zoom_mode_set];
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
2012-03-29 04:09:45 -07:00
|
|
|
else if (!strcmp(param->name, "paused"))
|
2010-04-01 07:22:45 -07:00
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
param->i = elm_photocam_paused_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
2014-01-23 03:08:10 -08:00
|
|
|
external_photocam_params_parse(void *data EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
|
|
|
const Eina_List *params)
|
2010-04-01 07:22:45 -07:00
|
|
|
{
|
|
|
|
Elm_Params_Photocam *mem;
|
|
|
|
Edje_External_Param *param;
|
|
|
|
const Eina_List *l;
|
|
|
|
|
|
|
|
mem = calloc(1, sizeof(Elm_Params_Photocam));
|
|
|
|
if (!mem)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(params, l, param)
|
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
if (!strcmp(param->name, "file"))
|
|
|
|
mem->file = eina_stringshare_add(param->s);
|
|
|
|
else if (!strcmp(param->name, "zoom"))
|
|
|
|
{
|
|
|
|
mem->zoom = param->d;
|
|
|
|
mem->zoom_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "zoom mode"))
|
|
|
|
mem->zoom_mode = eina_stringshare_add(param->s);
|
|
|
|
else if (!strcmp(param->name, "paused"))
|
|
|
|
{
|
|
|
|
mem->paused = !!param->i;
|
|
|
|
mem->paused_exists = EINA_TRUE;
|
|
|
|
}
|
2010-04-01 07:22:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2014-01-06 06:30:02 -08:00
|
|
|
static Evas_Object *external_photocam_content_get(void *data EINA_UNUSED,
|
2014-01-23 03:08:10 -08:00
|
|
|
const Evas_Object *obj EINA_UNUSED,
|
|
|
|
const char *content EINA_UNUSED)
|
2010-08-01 10:29:20 -07:00
|
|
|
{
|
2014-01-23 03:08:10 -08:00
|
|
|
ERR("No content.");
|
|
|
|
return NULL;
|
2010-08-01 10:29:20 -07:00
|
|
|
}
|
|
|
|
|
2010-04-01 07:22:45 -07:00
|
|
|
static void
|
|
|
|
external_photocam_params_free(void *params)
|
|
|
|
{
|
|
|
|
Elm_Params_Photocam *mem = params;
|
|
|
|
|
|
|
|
if (mem->file)
|
|
|
|
eina_stringshare_del(mem->file);
|
|
|
|
if (mem->zoom_mode)
|
|
|
|
eina_stringshare_del(mem->zoom_mode);
|
|
|
|
free(mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Edje_External_Param_Info external_photocam_params[] = {
|
2014-01-23 03:08:10 -08:00
|
|
|
DEFINE_EXTERNAL_COMMON_PARAMS,
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("file"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_DOUBLE("zoom"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL("zoom mode", "manual", choices),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL("paused"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
|
2010-04-01 07:22:45 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_EXTERNAL_ICON_ADD(photocam, "photocam");
|
|
|
|
DEFINE_EXTERNAL_TYPE_SIMPLE(photocam, "Photocam");
|