Fix issues reported by coverity scan in recent changes to customdata code.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 1 Oct 2013 12:48:41 +0000 (12:48 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 1 Oct 2013 12:48:41 +0000 (12:48 +0000)
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/mesh.c

index 1521ec8467ee88944be3b223640e1425cde08c75..13d8c0380ab00fc5d798eb9970e0381a981d1358 100644 (file)
@@ -1463,8 +1463,7 @@ int CustomData_get_named_layer_index(const CustomData *data, int type, const cha
 
        for (i = 0; i < data->totlayer; ++i)
                if (data->layers[i].type == type)
-                       if ((!name && !data->layers[i].name) ||
-                           (strcmp(data->layers[i].name, name) == 0))
+                       if (strcmp(data->layers[i].name, name) == 0)
                                return i;
 
        return -1;
@@ -1970,11 +1969,9 @@ static void CustomData_copy_data_layer(const CustomData *source, CustomData *des
        dest_offset = dest_index * typeInfo->size;
 
        if (!src_data || !dest_data) {
-               if (src_data != NULL && dest_data != NULL) {
-                       printf("%s: warning null data for %s type (%p --> %p), skipping\n",
-                              __func__, layerType_getName(source->layers[src_i].type),
-                              (void *)src_data, (void *)dest_data);
-               }
+               printf("%s: warning null data for %s type (%p --> %p), skipping\n",
+                          __func__, layerType_getName(source->layers[src_i].type),
+                          (void *)src_data, (void *)dest_data);
                return;
        }
 
index 56e6e237d57a160b31b23fd843864539e1ffcd55..a77f768835aee58262bd8099c30dbee0e1aa8ff4 100644 (file)
@@ -645,7 +645,7 @@ bool BKE_mesh_uv_cdlayer_rename_index(Mesh *me, const int poly_index, const int
        }
        cdlp = &pdata->layers[poly_index];
        cdlu = &ldata->layers[loop_index];
-       cdlf = do_tessface ? &fdata->layers[face_index] : NULL;
+       cdlf = fdata && do_tessface ? &fdata->layers[face_index] : NULL;
 
        BLI_strncpy(cdlp->name, new_name, sizeof(cdlp->name));
        CustomData_set_layer_unique_name(pdata, cdlp - pdata->layers);
@@ -662,8 +662,10 @@ bool BKE_mesh_uv_cdlayer_rename_index(Mesh *me, const int poly_index, const int
                                CustomData_set_layer_unique_name(ldata, cdlu - ldata->layers);
                                break;
                        case 2:
-                               BLI_strncpy(cdlf->name, cdlp->name, sizeof(cdlf->name));
-                               CustomData_set_layer_unique_name(fdata, cdlf - fdata->layers);
+                               if (cdlf) {
+                                       BLI_strncpy(cdlf->name, cdlp->name, sizeof(cdlf->name));
+                                       CustomData_set_layer_unique_name(fdata, cdlf - fdata->layers);
+                               }
                                break;
                }
        }