aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/llcrc.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/llmath/llcrc.cpp
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/llmath/llcrc.cpp')
-rw-r--r--linden/indra/llmath/llcrc.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/linden/indra/llmath/llcrc.cpp b/linden/indra/llmath/llcrc.cpp
index 4194432..1c0aa5d 100644
--- a/linden/indra/llmath/llcrc.cpp
+++ b/linden/indra/llmath/llcrc.cpp
@@ -161,9 +161,15 @@ void LLCRC::update(const U8* buffer, U32 buffer_size)
161 } 161 }
162} 162}
163 163
164void LLCRC::update(const char *filename) 164void LLCRC::update(const char* filename)
165{ 165{
166 FILE *fp = LLFile::fopen(filename, "rb"); 166 if (!filename)
167 {
168 llerrs << "No filename specified" << llendl;
169 return;
170 }
171
172 FILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
167 173
168 if (fp) 174 if (fp)
169 { 175 {
@@ -172,12 +178,15 @@ void LLCRC::update(const char *filename)
172 178
173 fseek(fp, 0, SEEK_SET); 179 fseek(fp, 0, SEEK_SET);
174 180
175 U8 *data = new U8[size]; 181 if (size > 0)
176 fread(data, size, 1, fp); 182 {
177 fclose(fp); 183 U8* data = new U8[size];
184 fread(data, size, 1, fp);
185 fclose(fp);
178 186
179 update(data, size); 187 update(data, size);
180 delete[] data; 188 delete[] data;
189 }
181 } 190 }
182} 191}
183 192
@@ -186,7 +195,7 @@ void LLCRC::update(const char *filename)
186BOOL LLCRC::testHarness() 195BOOL LLCRC::testHarness()
187{ 196{
188 const S32 TEST_BUFFER_SIZE = 16; 197 const S32 TEST_BUFFER_SIZE = 16;
189 const char TEST_BUFFER[TEST_BUFFER_SIZE] = "hello &#$)$&Nd0"; 198 const char TEST_BUFFER[TEST_BUFFER_SIZE] = "hello &#$)$&Nd0"; /* Flawfinder: ignore */
190 LLCRC c1, c2; 199 LLCRC c1, c2;
191 c1.update((U8*)TEST_BUFFER, TEST_BUFFER_SIZE - 1); 200 c1.update((U8*)TEST_BUFFER, TEST_BUFFER_SIZE - 1);
192 char* rh = (char*)TEST_BUFFER; 201 char* rh = (char*)TEST_BUFFER;