winevt_c 0.4.0-x86-mingw32 → 0.4.1-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e0861d47eb17f69967842c4ca2ee4b95bf878a5e8fd00037f290f9c5d427169
4
- data.tar.gz: c215213706cebf991096c43a2d2908aa451c565fa1ef260419a99eac2e1048d7
3
+ metadata.gz: 9524469dfab709e5ccab74919030550448efb1565a53a5841cfb76c0d611d9f5
4
+ data.tar.gz: 5c6ec4637fa2e018f0673518defef25cc9d5a32fac0bfa624c27ed71c624d8b4
5
5
  SHA512:
6
- metadata.gz: c60e58ef313ea9d21c8d481649c8a7e302908d3a24ba69f253ed3706fc339187aa87ea779b10c69d31d77d925530bf15edd8aec3b628032f7bacddc7a75a3658
7
- data.tar.gz: dac9f1488b6ee48dc55749c195b95b92f602ac96f6725f35651ae06d697fcd1ab7a114a045075cd2de61acd321ec703ef5c6e584248174a41afe83da54ccb6b7
6
+ metadata.gz: 189388df964b905a4ea276a5704b7deda991f35b8f4ada4591725ec99a50929545a68e4b69c95210f9ef621ef9bc420397de33ad5e99ccc4ef77becf56c15190
7
+ data.tar.gz: 567defa57d64a8941312641cae88a8672c1218739aa0b281d971eb694f6fafebba893faac22700f4c87bf34950d5c048527627393fe605ae07915d6168e7e0f4
@@ -148,6 +148,8 @@ rb_winevt_query_render(VALUE self)
148
148
 
149
149
  utf8str = rb_utf8_str_new_cstr(result);
150
150
  free_allocated_mbstr(result);
151
+ if (wResult != NULL)
152
+ free(wResult);
151
153
 
152
154
  return utf8str;
153
155
  }
@@ -164,6 +164,8 @@ rb_winevt_subscribe_render(VALUE self)
164
164
 
165
165
  utf8str = rb_utf8_str_new_cstr(result);
166
166
  free_allocated_mbstr(result);
167
+ if (wResult != NULL)
168
+ free(wResult);
167
169
 
168
170
  return utf8str;
169
171
  }
@@ -69,7 +69,7 @@ WCHAR* render_event(EVT_HANDLE handle, DWORD flags)
69
69
  rb_raise(rb_eWinevtQueryError, "ErrorCode: %d\nError: %s\n", status, RSTRING_PTR(errmsg));
70
70
  }
71
71
 
72
- result = buffer;
72
+ result = _wcsdup(buffer);
73
73
 
74
74
  if (buffer)
75
75
  xfree(buffer);
@@ -214,6 +214,7 @@ VALUE get_values(EVT_HANDLE handle)
214
214
  result = wstr_to_mbstr(CP_UTF8, tmpWChar, -1);
215
215
  rb_ary_push(userValues, rb_utf8_str_new_cstr(result));
216
216
  free_allocated_mbstr(result);
217
+ CoTaskMemFree(tmpWChar);
217
218
  } else {
218
219
  rb_ary_push(userValues, rb_utf8_str_new_cstr("?"));
219
220
  }
@@ -253,6 +254,7 @@ VALUE get_values(EVT_HANDLE handle)
253
254
  result = wstr_to_mbstr(CP_UTF8, tmpWChar, -1);
254
255
  rb_ary_push(userValues, rb_utf8_str_new_cstr(result));
255
256
  free_allocated_mbstr(result);
257
+ LocalFree(tmpWChar);
256
258
  } else {
257
259
  rb_ary_push(userValues, rb_utf8_str_new_cstr("?"));
258
260
  }
@@ -300,6 +302,7 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
300
302
  LPVOID lpMsgBuf;
301
303
  WCHAR* prevBuffer;
302
304
  WCHAR *message;
305
+ WCHAR *reallocatedMessage;
303
306
 
304
307
  message = (WCHAR *)xmalloc(sizeof(WCHAR) * BUFSIZE);
305
308
  if (!EvtFormatMessage(hMetadata, handle, 0xffffffff, 0, NULL, EvtFormatMessageEvent, BUFSIZE, message, &bufferSizeNeeded)) {
@@ -328,7 +331,7 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
328
331
  MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
329
332
  (WCHAR *) &lpMsgBuf, 0, NULL);
330
333
 
331
- result = (WCHAR *)lpMsgBuf;
334
+ result = _wcsdup((WCHAR *)lpMsgBuf);
332
335
  LocalFree(lpMsgBuf);
333
336
 
334
337
  goto cleanup;
@@ -342,7 +345,11 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
342
345
 
343
346
  if (status == ERROR_INSUFFICIENT_BUFFER) {
344
347
  prevBuffer = message;
345
- message = (WCHAR *)realloc(prevBuffer, sizeof(WCHAR) * bufferSizeNeeded);
348
+ reallocatedMessage = (WCHAR *)realloc(prevBuffer, sizeof(WCHAR) * bufferSizeNeeded);
349
+ if (reallocatedMessage == NULL) {
350
+ rb_raise(rb_eWinevtQueryError, "Reallocation failed.");
351
+ }
352
+ message = reallocatedMessage;
346
353
 
347
354
  if(!EvtFormatMessage(hMetadata, handle, 0xffffffff, 0, NULL, EvtFormatMessageEvent, bufferSizeNeeded, message, &bufferSizeNeeded)) {
348
355
  status = GetLastError();
@@ -370,7 +377,7 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
370
377
  MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
371
378
  (WCHAR *) &lpMsgBuf, 0, NULL);
372
379
 
373
- result = (WCHAR *)lpMsgBuf;
380
+ result = _wcsdup((WCHAR *)lpMsgBuf);
374
381
  LocalFree(lpMsgBuf);
375
382
 
376
383
  goto cleanup;
@@ -382,7 +389,7 @@ static WCHAR* get_message(EVT_HANDLE hMetadata, EVT_HANDLE handle)
382
389
  }
383
390
  }
384
391
 
385
- result = message;
392
+ result = _wcsdup(message);
386
393
 
387
394
  cleanup:
388
395
 
@@ -450,7 +457,7 @@ WCHAR* get_description(EVT_HANDLE handle)
450
457
  goto cleanup;
451
458
  }
452
459
 
453
- result = get_message(hMetadata, handle);
460
+ result = _wcsdup(get_message(hMetadata, handle));
454
461
 
455
462
  #undef BUFSIZE
456
463
 
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module Winevt
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winevt_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-28 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler