}
}
+static int
+_tbm_surface_check_file_is_valid(const char* path, int del_link)
+{
+ char *real_path;
+
+ if (!path)
+ return 0;
+
+ real_path = realpath(path, NULL);
+ if (real_path && strncmp(path, real_path, strlen(path))) {
+ if (del_link)
+ unlink(path);
+ free(real_path);
+
+ return 0;
+ }
+
+ if (real_path)
+ free(real_path);
+
+ return 1;
+}
+
int
tbm_surface_internal_is_valid(tbm_surface_h surface)
{
_tbm_surface_internal_dump_file_raw(const char *file, void *data1, int size1,
void *data2, int size2, void *data3, int size3)
{
- FILE *fp = fopen(file, "w+");
- TBM_RETURN_IF_FAIL(fp != NULL);
+ FILE *fp;
unsigned int *blocks;
+ if (!_tbm_surface_check_file_is_valid(file, 1))
+ TBM_LOG_E("%s is symbolic link\n", file);
+
+ fp = fopen(file, "w+");
+ TBM_RETURN_IF_FAIL(fp != NULL);
+
blocks = (unsigned int *)data1;
fwrite(blocks, 1, size1, fp);
_tbm_surface_internal_dump_file_png(const char *file, const void *data, int width, int height)
{
unsigned int *blocks = (unsigned int *)data;
- FILE *fp = fopen(file, "wb");
- TBM_RETURN_IF_FAIL(fp != NULL);
+ FILE *fp;
const int pixel_size = 4; // RGBA
png_bytep *row_pointers;
int depth = 8, y;
+ if (!_tbm_surface_check_file_is_valid(file, 1))
+ TBM_LOG_E("%s is symbolic link\n", file);
+
+ fp = fopen(file, "wb");
+ TBM_RETURN_IF_FAIL(fp != NULL);
+
png_structp pPngStruct = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if (!pPngStruct) {